Logging With PHP (
Page 1 of 9 )
Want to log script activity in your Web application, but have
no clue where to begin? Take our handy tour of PHP's logging functions,
and find out how simple it really is.I have to warn you not to be misled by the title of this article. It isn't
really about cutting down trees with PHP.
I know that PHP is the Swiss
Army knife of Web scripting languages, but I don't think its developers have
come up with a way to have it reduce our tree cover (at least not yet). Rather,
this article is about a different sort of logging - the sort which involves
writing messages to files or devices on a regular basis, and using these
messages to "do something useful", be it generating a report or building an
audit trail for activity tracking.
Over the next few pages, I'm going to
take a quick look at the various mechanisms available to log script activity via
PHP, demonstrating both built-in functions and add-on classes that allow you to
add logging functionality to your applications. I'll also spend some time on the
PHP functions and configuration options related to logging, demonstrating how,
for example, PHP errors can be sent to the Web server error log or emailed to an
administrator when they are over a particular priority level.
My primary
audience for this tutorial is the novice to intermediate PHP user - if you're an
advanced user, you probably already know enough about logging with PHP, and
might prefer to skip the rest of this article in favour of more nutritious fare.
Everyone else - keep reading!