PHP code example of stuzzo / monolog-extender
1. Go to this page and download the library: Download stuzzo/monolog-extender 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/ */
stuzzo / monolog-extender example snippets
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
// create a log channel
$log = new Logger('request');
$handler = new StreamHandler('path/to/your.log', Logger::WARNING);
$formatter = new \Stuzzo\Monolog\Formatter\StreamFormatter(null, 'Y-m-d H:i:s');
$handler->setFormatter($formatter);
$log->pushHandler($handler);
try {
throw new \RuntimeException('Something happen');
} catch (\Exception $exception) {
$log->critical('Error', ['exception' => $exception]);
}