Symfony2/Monolog: Log Level - only show app.INFO?
You have to make a new logger service, which should be used it in your classes. Like this, config.yml:
services: my_logger: class: Monolog\Logger arguments: [my_info] calls: - [pushHandler, [@my_log_handler]] my_log_handler: class: Monolog\Handler\StreamHandler arguments: [%kernel.root_dir%/logs/my_info.log, 100]
Usage (in Controller
, for example):
$this->get('my_logger')->info('info message');
More detailed information in symfony cookbook.
With version 2.4 and up (beware, the release cycle of the MonologBundle is not syncronized with symfony anymore) of the MonologBundle, you can now define new channels very simple via configuration, without defining services.
monolog: channels: ["my_channel"] handlers: file: type: stream path: %kernel.logs_dir%/mylogfile.log level: info channels: my_channel
Now simply get the automatically created logger for the new channel in your controller:
$logger = $this->get('monolog.logger.my_channel');$logger->info('somelogcontent');
I know old question, but this new feature from the MonologBundle
~2.4
should be mentioned.