PHP code example of bugsnag / bugsnag-psr-logger

1. Go to this page and download the library: Download bugsnag/bugsnag-psr-logger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bugsnag / bugsnag-psr-logger example snippets


$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');

$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');

$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');