tags:

views:

2743

answers:

4

I'm looking for a simple PHP logging framework. What I need is something simple to plug-in into our PHP project, allowing for some configuration file to state what to log (INFOrmation, DEBUGging, etc.) and where to log it (MySQL, syslog, logfile...)

I've seen in Java you have log4j and for .NET you have log4net. In PHP there are some projects starting to mimic those (see log4php and log5php) but both are still not mature enough.

Thanks

+3  A: 

Probably PEAR's Log?

(I haven't used it)

Milen A. Radev
+6  A: 

Zend Framework has a nice logging class Zend_Log. Zend_Log has you set a Writer, Filter, and a Formatter which should give you a fairly robust amount of control.

I can't think of what it's dependencies are right off the bat, but if you do decide to use it, it's quick and easy to use and the Zend Framework comes with a Writer class that uses the Zend_Wildfire component (FirePHP), which would allow you to log directly to Firebug in your browser.

The only problem is you will have to spend some time extracting the logging classes out of the Zend Framework, but it shouldn't be too difficult. If it has no major dependencies you just grab Log.php and the Log\ folder from the Zend Framework download.

dcousineau
Zend_Log also depends on Zend_Exception. Zend_Log_Writer_Firebug depends on the Zend_Wildfire component, which in turn depends on Zend_Loader, Zend_Json, and Zend_Controller.
Bill Karwin
DLL hell returns :P
dcousineau
+1  A: 

What qualifies a logging package as 'mature enough'?

I'm happy for log4php. I have it configured to write to syslog. In my setup, the syslog messages are centralized.

Gary Richardson
Are we talking about the same log4php? I see here http://incubator.apache.org/log4php/download.html that no releases have yet been made.
Pablo Alsina
Yup. No releases. Code works fine for me.
Gary Richardson
+5  A: 

kLogger so far looks the best http://codefury.net/2008/07/klogger-a-simple-logging-class-for-php/

shaiss
+1 for klogger, its really awesome
Sumit Ghosh