use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); // add records to the log $log->warning('Foo'); $log->error('Bar');
use Monolog\Logger; use Monolog\Handler\StreamHandler; use Monolog\Handler\SwiftMailerHandler; // create a log channel $log = new Logger('name'); // add handlers $log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); $log->pushHandler(new SwiftMailerHandler($mailer, Logger::ERROR)); // add records to the log $log->warning('Foo'); $log->error('Bar');
use Monolog\Logger; use Monolog\Handler\StreamHandler; use Monolog\Processor\IntrospectionProcessor; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); // add a processor $log->pushProcessor(new IntrospectionProcessor()); // add records to the log $log->warning('Foo'); $log->error('Bar');This example demonstrates how to customize log messages using a `Processor`. In this case, we use the `IntrospectionProcessor` class to add information about the caller of the log message to the log record. In summary, PHP Monolog Logger is a package library that allows easy logging in PHP applications. It provides a simple and unified API for different logging libraries and frameworks. The package library can be determined by the namespace 'Monolog'.