Answer the question
In order to leave comments, you need to log in
Trouble with logger in symfony, what's wrong?
I connect the logger as follows, but it still does not write to the file, but only to the console:
#app/config/config_dev.yml
monolog:
handlers:
search:
type: stream
level: error
path: "%kernel.logs_dir%/search_log.log"
channels: [search]
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [!event, !search]
console:
type: console
channels: [!event, !doctrine, !search]
#MyBundle/Resources/config/services.yml
services:
app.logger_search:
class: Symfony\Bridge\Monolog\Logger
arguments: ["@logger"]
tags:
- {name: monolog.logger, channel: search}
#MyController.php
/**
* @Route("/test")
*/
public function test()
{
$this->get("app.logger_search")->error("Test");
return $this->json("test");
}
Answer the question
In order to leave comments, you need to log in
Look at the Monolog settings in config_dev.yml.
You have handler specified console.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question