Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Symfony still log to a dev.log file, even when I didn't define it in a loghandler?

During the execution of Symfony Commands, I want to log messages to a different file. I have read the Symfony and Monolog documentation, and it should work like I describe here. (Note that I know messages from the 'doctrine', 'event', ... channels will still be logged by the main handler, but that doesn't matter for me)

In my config.yml, I have this:

monolog:
    channels: [commandline]
    handlers:
        main:
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.main.log"
            level: debug
            channels: [!commandline]
        commandline:
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.commandline.log"
            level: debug
            channels: commandline
        stdout:
            type:  stream
            path:  "php://stdout"
            level: debug
            channels: commandline
        mail:
            type:         stream
            action_level: alert
            handler:      buffered_mail
        buffered_mail:
            type:    buffer
            handler: swift
        swift:
            type:       swift_mailer
            from_email: [email protected]
            to_email:   [email protected]
            subject:    "Something went wrong"
            level:      alert

I'm expecting to have 2 log-files: dev.main.log and dev.commandline.log. But I'm still having a third log-file: dev.log that logs all messages. I don't seem to find where that loghandler is defined and how I can prevent it from logging things...

If anyone could point me in the right direction, that would be nice!

btw, i'm using:

  • symfony 2.3
  • monolog-bundle 2.4

EDIT

There is no monolog section in the config_dev.yml

like image 557
Stivni Avatar asked Dec 05 '13 10:12

Stivni


1 Answers

REMOVE monolog.handlers.mainfrom config_dev.yml.

It usally contains path: "%kernel.logs_dir%/%kernel.environment%.log"

config _dev.yml (default)

monolog:
    handlers:
        main:   # <- remove this handler
            type:   stream
            path:   "%kernel.logs_dir%/%kernel.environment%.log" #<- logs/dev.log
            level:  debug

Remove the main handler from this config file.

like image 186
Nicolai Fröhlich Avatar answered Sep 23 '22 12:09

Nicolai Fröhlich