monolog/monolog's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
Monolog/monolog is a composer package that significantly enhances the logging capabilities for PHP applications. It provides an array of features that allows for sending your logs to several destinations, including files, sockets, inboxes, databases, and various web services. This robust package supports advanced logging strategies, giving developers extensive control over how they handle logging information in their applications. Compatible with the PSR-3 interface, it ensures maximum interoperability for your libraries and flexibility for future logger replacements.
To make use of the monolog/monolog package, first, install the latest version using
composer require monolog/monolog on your terminal. Once the package is installed, you can start integrating it into your PHP projects. Here's a basic usage example:
<?php use Monolog\Level; use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Level::Warning)); // add records to the log $log->warning('Foo'); $log->error('Bar');
In this snippet, a log channel is created, a handler is pushed to the log channel, and then the logger is used to record warning and error messages. The StreamHandler writes the log messages to a specified path with a designated log level.
The official documentation for the monolog/monolog package can be found within the GitHub repository at https://github.com/Seldaek/monolog.git. This includes detailed information about its installation, basic and advanced usage instructions, details about handlers, formatters, and processors, utilities, how to extend monolog, and the structure of log records. These guides are instrumental for developers looking to leverage the full capabilities of this complex logging package, ensuring they can effectively apply and tailor it to their unique project requirements.