Why does Symfony still log to a dev.log file, even when I didn't define it in a loghandler?
REMOVE monolog.handlers.main
from 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.
If anyone comes across this and is still interested in why this happens, the debug handler is injected in the \Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\DebugHandlerPass::process() method...
class DebugHandlerPass implements CompilerPassInterface{ // ... public function process(ContainerBuilder $container) { if (!$container->hasDefinition('profiler')) { return; } if (!$container->getParameter('kernel.debug')) { return; } $debugHandler = new Definition('%monolog.handler.debug.class%', array(Logger::DEBUG, true)); $container->setDefinition('monolog.handler.debug', $debugHandler); foreach ($this->channelPass->getChannels() as $channel) { $container ->getDefinition($channel === 'app' ? 'monolog.logger' : 'monolog.logger.'.$channel) ->addMethodCall('pushHandler', array(new Reference('monolog.handler.debug'))); } }}
As you can see, this pushes a new handler on to every registered channel, thus overriding any other handlers that might already have been added.