[OWASP_PHPSEC] Log4PHP Overview
rahul300chaudhary400 at gmail.com
Wed Jul 17 06:01:25 UTC 2013
Log4PHP is a library in Apache Projects which is used for event logging
inside PHP. Its a pretty nice library with most of the functions that one
Here is how it works:
They have separated the logging into three components.
First you define a logger that contains functions to log something. You can
define as many loggers as you like, specific to each class or however you
like...you can even make those loggers in hierarchy where the child loggers
can inherit from parent loggers.
Note that loggers themselves are not capable of logging...they just are
"plugs" that has to connected to other components. Its like preparing to
Then there comes "appenders". These define the places where your log files
would go. e.g. syslog, console, files, DB etc.... One logger can have many
appenders. So suppose you append console and files to your logger, then
your logs would go to both of them.
Lastly there are "layouts". These are responsible for your logs to be
converted to string and store them in the proper place. Every appender must
have a layout defined, otherwise default is used.
For configurations, you can define all of the above via two methods:
1) you can have a XML file to represent what loggers would use what
appenders and layout. Pretty neat.
2) You can define a PHP array to do the above. Not so neat.
Additonally there are levels for logging (total 6 levels) - high level logs
such as FATAL ERRORS and low level logs such as INFO, DEBUG etc. Since its
an hierarchy, you define a level for your logs. Suppose you choose level 3.
Then your logs would be available for level 3 and above. i.e. logs will be
recoreded for the current logs and levels above it.
The structure of the entire library is not at all complicated. Since the
components are divided into 3 types - logger, appender, layout, - you can
choose any storage type in the appenders - file, DB, etc ...anything...
Hope this helps. :)
Ph - 412-519-9634
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the OWASP_PHP_Security_Project