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
Jul 26, 2012 @ 16: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.

tagged: json apache log format logformat jsondecode

Link:

ProDevTips.com:
jQuery JSON with PHP json_encode and json_decode
Aug 18, 2008 @ 15:22:04

On the ProDevTips blog, Henrik shows an example of the "perfect combination" of PHP's json functionality and a powerful javascript library, jQuery.

Today I looked for a replacement for my old jspanserializer.js script that I can't even remember where I found anymore. Turns out that I wont have to either, I can forget it. From now on I'll use jQuery JSON instead.

A code example is included to show the simplicity.

tagged: json jquery jsonencode jsondecode example

Link:


Trending Topics: