1. Go to this page and download the library: Download macbre/monolog-utils library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
macbre / monolog-utils example snippets
try {
// do something
}
catch (NastyException $ex) {
$logger->error('Something bad happended', [
'exception' => $ex
]);
}
$logger->error('Foo Bar', [
'size' => 42
]);
$logger = new Monolog\Logger('my.app');
$logger->pushProcessor(new Macbre\Logger\Processors\ExceptionProcessor());
$logger->pushProcessor(new Macbre\Logger\Processors\RequestIdProcessor());
// Syslog and JSON formatter for elastic / Kibana
$syslog = new Monolog\Handler\SyslogUdpHandler('127.0.0.1', 514, LOG_USER, Monolog\Logger::INFO);
$syslog->setFormatter(new Macbre\Logger\Formatters\JsonFormatter());
$logger->pushHandler($syslog);
// and now let's use the logger...
$logger->error('Foo Bar', [
'exception' => newException('An error', 123),
'size' => 42
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.