$log = new \Monolog\Logger('my_logger'); $log->pushHandler(new \Monolog\Handler\StreamHandler('path/to/your.log', \Monolog\Logger::DEBUG)); $log->debug('Debug message'); $log->info('Info message'); $log->warning('Warning message'); $log->error('Error message');
$log = new \Monolog\Logger('my_logger'); $log->pushHandler(new \Monolog\Handler\SwiftMailerHandler($transport, $message, \Monolog\Logger::WARNING)); $log->warning('Warning message');This example creates a new logger with the name 'my_logger' and adds a handler that sends log messages via email using the SwiftMailer library. It then logs a warning message which will trigger the handler to send an email to the specified email address. In both examples, the package library used is Monolog.