News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Lorna Mitchell:
Logging to Stdout with Monolog
June 09, 2014 @ 09:08:10

Lorna Mitchell has a quick post today showing how you can use the popular Monolog logging library to log messages and data to stdout, the standard output stream of whatever is executing the script.

My worker scripts have really basic logging (as in, they echo when something happens, and I can see those in the supervisord logs). Which is kind of okay, but I wanted to at least add timestamps in to them, and maybe send emails when something REALLY bad happened. I'm a huge fan of Monolog so I grabbed that, but it wasn't immediately obvious which of the many and varied options I would need for this fairly simple addition. It turns out that the right thing to use is the ErrorLogHandler.

She includes a few lines of sample code that use the "ErrorLogger" to output the message. It includes the log level, a timestamp, the message itself and any additional contextual information you pass in.

0 comments voice your opinion now!
monolog stdout output example library logging

Link: http://www.lornajane.net/posts/2014/logging-to-stdout-with-monolog

blog comments powered by Disqus

Similar Posts

Roadsend.com: SiteManager Library Being Ported to PHP5

LoopPo Blog: PDML PHP tricks

Hasin Hayder's Blog: Working with models in orchid

Jim Plush's Blog: Why Your PHP app NEEDS a Circuit Breaker

Richard Davey\'s Blog: dBug - var_dump with style!


Community Events





Don't see your event here?
Let us know!


package laravel library opinion podcast install release series deployment symfony interview tips zendserver framework introduction community language api update list

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework