Official Bugsnag PHP PSR Logger.
The Bugsnag PHP PSR logger is an implementation of the Fig PSR logging standard that provides a standard interface to logging to Bugsnag.
bugsnag/bugsnag-psr-logger to your
The library provides two loggers,
BugsnagLogger will automatically send a notification to Bugsnag if it receives a message with a severity higher than
info. This will allow you to notify of any handled exceptions through interfacing the logger directly with the framework you are using. Ensure that the logger can communicate with the
bugsnag-php library by passing the
client object into it on creation.
$bugsnag = Bugsnag\Client::make('YOUR-API-KEY-HERE'); $logger = new Bugsnag\PsrLogger\BugsnagLogger($bugsnag); # Will send a notification to bugsnag $logger.error('An error occurred');
If you wish to use a separate logger alongside
BugsnagLogger you will need to use
MultiLogger. By passing it an array of
Logger objects on construction,
MultiLogger will call into each passed
Logger in turn when a message is logged.
$logger = new Bugsnag\PsrLogger\BugsnagLogger($bugsnag); $mySecondLogger = new Logger(); $multiLogger = new Bugsnag\PsrLogger\MultiLogger([$logger, $mySecondLogger]); # Will log to $mySecondLogger and send a notification to bugsnag through $logger $multiLogger.error('An error occurred');
The default level at which logs will be sent to Bugsnag is
Psr\Log\LogLevel::NOTICE. This can be overridden using the
$logger = new Bugsnag\PsrLogger\BugsnagLogger($bugsnag); # Will not send a notification to bugsnag by default $logger->info('Some interesting information'); $logger->setNotifyLevel(Psr\Log\LogLevel::INFO); # Will send a notification to bugsnag $logger->info('Some more interesting information');
For more information on integrating the loggers into specific frameworks see the individual setup information found in the bugsnag-php documentation.
All contributors are welcome! For information on how to build, test and release
bugsnag-psr-logger, see our contributing guide. Feel free
to comment on existing issues
for clarification or starting points.
The Bugsnag PSR logger is free software released under the MIT License. See LICENSE.txt for details.