10/07/2014 - SYMFONY
Bu örnek iki tane farklı log dosyası yaratmak için, iki tane farklı channel kullanır. Ayrıca farklı controller içinde kullanılırlar.
"require": {
"symfony/monolog-bundle": "~2.4"
}
composer update symfony/monolog-bundle
Aşağidaki notları okuyun.
monolog:
channels: ["student", "subject"]
handlers:
student:
type: stream
path: %kernel.logs_dir%/%kernel.environment%_student.log # Creates dev_student.log file
channels: ["student"] # Force to handle only student channel
subject:
type: stream
path: %kernel.logs_dir%/%kernel.environment%_subject.log # Creates dev_subject.log file
channels: ["subject"] # Force to handle only subject channel
main:
channels: ["!student", "!subject"] # Force main channel to ignore student and subject channels
console:
channels: ["!doctrine", "!student", "!country"] # Force console channel to ignore student and subject channels as well
Class StudentController extends Controller
{
public function indexAction()
{
$this->get('monolog.logger.student')->info('inanzzz info message');
}
}
# app/logs/dev_student.log
[2014-06-07 21:13:18] student.INFO: inanzzz info message [] []
Class StudentController extends Controller
{
public function indexAction()
{
$this->get('monolog.logger.subject')->warning('inanzzz warning message');
}
}
# app/logs/dev_subject.log
[2014-06-07 21:13:18] subject.WARNING: inanzzz warning message [] []