Skip to content

Instantly share code, notes, and snippets.

@ckdarby
Created June 27, 2013 14:07
Show Gist options
  • Save ckdarby/5876705 to your computer and use it in GitHub Desktop.
Save ckdarby/5876705 to your computer and use it in GitHub Desktop.
Just messing around with monolog
<?php
include_once('vendor/autoload.php');
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Formatter\LineFormatter;
//Create a log channel
$log = new Logger('Test');
//Create formatter for different logging than default
$dateFormat = "Y n j, g:i a";
$output = "%datetime% > %level_name% > %message% %context% %extra%\n";
$formatter = new LineFormatter($output, $dateFormat);
//Create handler
$handler = new StreamHandler('/var/log/mono', Logger::WARNING);
//Set formatter
$handler->setFormatter($formatter);
//Set Handler
$log->pushHandler($handler);
//Add records
$log->addWarning('Foo');
$log->addError('Bar');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment