News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Bob Majdak:
Apache access logging in JSON format
July 26, 2012 @ 11:42:02

Bob Majdak has a quick new post to his site showing you how to log messages to Apache using a JSON format instead of the usual single-line information.

So this past week I have been doing a lot of logging, parsing, and graphing. I was sitting there wondering what I could do to make the Apache access logs easier to work with. Then it hit me, a brilliant stroke of win: why not format it in JSON? Then in my log parser I could just json_decode it! As far as I know there are no tricks to make Apache do this for you, so really all we have to do is define a custom log format that happens to look like JSON.

He includes the "LogFormat" line you'll need to add to your Apache configuration to make it log the JSON and a bit of PHP to help you pull in the file's contents and parse each line.

0 comments voice your opinion now!
json apache log format logformat jsondecode


blog comments powered by Disqus

Similar Posts

Federico Cargnelutti's Blog: Format a time interval with the requested granularity

PHPMac.com: Building and Installing Apache 2.2.2 and PHP 5.1.4 on Mac OS X 10.4.6

Mike Potter's Blog: PHP Tek Presentation Horrors

PHPMac.com: Building and Installing Apache 2 and PHP 5.1.1 on Mac OS X 10.4.3 Tiger

Utah PHP Users Group - February Meeting, 02.16.06 @ 7pm


Community Events





Don't see your event here?
Let us know!


symfony deployment install language interview voicesoftheelephpant release community laravel unittest framework api bugfix package podcast introduction library series opinion zendserver

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework