Log4php is a php port of Log4j, the most popular Java logging framework (see http://jakarta.apache.org/log4j/ for details).



  • Supports configuration through xml and properties file (same structure as log4j).
  • Supports File, RollingFile, DailyFile, Echo, Console, Mail, PEAR::Db, PHP error, Syslog or NT events and Socket appenders.
  • Supports Simple, TTCC, Pattern, Html and Xml Layouts.
  • Supports Nested (NDC) and Mapped (MDC) Diagnostic Contexts.
  • Switchable internal debug.

It can be used inside a class (see below) or inside a main/sub function.


  • PHP >= 4.1.x (to log caller location information PHP >= 3.2.0 is needed)
  • PEAR XML_Parser class (located in PEAR/XML/Parser.php by default) only for log4php version <= 0.3.


First read the original log4j documentation.
Then, read the log4php quick setup guide.
Finally, for further informations, browse the online api documentation.


Here is an example on how to use in your php code (usage.php).
For more examples see tests/ directory in the log4php distribution.
Take also a look at original log4j documentation.

Refer: http://www.vxr.it/log4php/#intro