0

I am currently running a Symfony 5 project in dev environment.

I would like to output requests logs (like 10:01:39 request.INFO Matched route "login_route") into a file.

I have the following config/packages/dev/monolog.yaml file:

monolog:
    handlers:
        main:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
            channels: [event]

With the YAML above, it logs correctly into the file /tmp/dev-logs/dev.log when I execute bin/console cache:clear.

But, it does not log anything when I perform requests on the application, no matter if I set channels: [request] or channels: ~ or even no channel param at all.

How can I edit the settings of that monolog.yaml file in order to log request channel logs ?

yivi
  • 42,438
  • 18
  • 116
  • 138
jean553
  • 621
  • 10
  • 29

1 Answers1

-1

I have found the answer! This is very specific to my configuration.

In fact, I have two Docker containers (that both mount the project directory as a volume) for development:

  • one for code edition (with a linter, syntax checker, specific vim configuration...etc...)
  • one to access the application through HTTP using PHP-FPM (the one that is used when I make HTTP requests on the app)

So, when I perform a bin/console cache:clear from the first container I use for development, it logs into the /tmp/dev-logs/dev.log file of that first container; but when I execute HTTP requests, it logs into the /tmp/dev-logs/dev.log file of that second container;

I was checking the first container file only while it was logging into the second container file instead. So, I was simply not checking the right file.

Everything works. :)

jean553
  • 621
  • 10
  • 29