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
monolog
section of yourconfig_dev.yml
to the question please. – Nicolai Fröhlichmonolog
both indev
andprod
config files butdev
DOES NOT record entries if I don't explicitly callapp_dev.php
. So, it's some minconfiguration that you have encountered... – Jovan Perovicfingers_crossed
strategy inmain
logger – Jovan Perovicmain
handler from hisconfig_dev
but didnt clear his (opcode-)cache or something like that. In symfony standard this default handler producinglogs/<env>.log
is configured inconfig.yml
/config_dev.yml
and nowhere else. The only other reason could be a missing path somewhere in the other handlers as%kernel.logs_dir%/%kernel.environment%.log
is the defaultValue of path. – Nicolai Fröhlich