This example creates two different channels for two different log files and both will be dedicated to their own controllers.


Add monolog bundle to composer.json


"require": {
"symfony/monolog-bundle": "~2.4"
}

Update composer


composer update symfony/monolog-bundle

Update config.yml


Read comment lines below.


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

StudentController


Class StudentController extends Controller
{
public function indexAction()
{
$this->get('monolog.logger.student')->info('inanzzz info message');
}
}

Result


# app/logs/dev_student.log
[2014-06-07 21:13:18] student.INFO: inanzzz info message [] []

SubjectController


Class StudentController extends Controller
{
public function indexAction()
{
$this->get('monolog.logger.subject')->warning('inanzzz warning message');
}
}

Result


# app/logs/dev_subject.log
[2014-06-07 21:13:18] subject.WARNING: inanzzz warning message [] []