Write symfony command log output to console AND FILE
Asked Answered
J

0

6

The setup is thus:

I have a command, which calls a function on service X which uses logger Y.

Currently, when run from the console, the log messages are output to the console (using the -v parameters). I would also like to output those messages to a file, regardless of the -v level.

Edit: Adding monolog config, as requested (though there's nothing interesting - it's the default).

monolog:
    channels: ['amz_update']
    handlers:
        main:
            type: stream
            path: '%kernel.logs_dir%/%kernel.environment%.log'
            level: emergency
            channels: ['!event']
        console:
            type: console
            process_psr_3_messages: false
            channels: ['!event', '!doctrine', '!console']
        # To follow logs in real time, execute the following command:
        # `bin/console server:log -vv`
        server_log:
            type: server_log
            process_psr_3_messages: false
            host: 127.0.0.1:9911
Jose answered 16/1, 2019 at 16:33 Comment(1)
You should post the monolog part of your config.yml.Damson

© 2022 - 2024 — McMap. All rights reserved.