Logging with Monolog

The PHP community provides several logging libraries for us to choose, such as Monolog, Analog, KLogger, Log4PHP, and others. Choosing the right library can be a daunting task. More so because we might decide to change the logging mechanism later on, which might leave us with a substantial amount of code to change. This is where the PSR-3 logging standard helps. Choosing a library that is standards-compliant makes it easier to reason with.

Monolog is one of the most popular PHP logging libraries. It is a free, MIT-licensed library that implements the PSR-3 logging standard. It allows us to easily sends our logs to files, sockets, inboxes, databases, and various web services.

We can easily install the Monolog library as ...

Get Mastering PHP 7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.