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.


This log message comes from the router_listener service. You can re-define it in services configuration file.

What I've done in my main bundle config/services.yml :

services:

    # ...

    router_listener:
        class:  %router_listener.class%
        arguments: ['@router', %request_listener.http_port%, %request_listener.https_port%]
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onEarlyKernelRequest }
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

It makes "Matched route ..." log messages not to be logged (as RouterListener doesn't have a logger service in its constructor arguments).