Set LogLevel to DEBUG without setting APP_ENV to debug
Asked Answered
B

2

6

I need to get verbose logging while sorting out issues in the migration. If I set the APP_ENV to debug like described in the Shopware 6 Tutorials, I will get memory issues all the time because the Symfony Framework will also enable debug mode and cause huge memory consumption. This is a known issue while running the Migration tool.

How can I set the Logger to a more verbose logging level without setting the whole stack into debug mode?

Bashful answered 21/7, 2022 at 10:29 Comment(0)
G
4

You could try and take the monolog config for dev and apply it to prod. Overwrite the config by creating {SHOPWARE_ROOT}/config/packages/prod/monolog.yaml with this content:

# copied from src/Core/Framework/Resources/config/packages/dev/monolog.yaml
monolog:
    handlers:
        main:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
            channels: ["!event","!doctrine"]
        console:
            type:   console
            process_psr_3_messages: false
            channels: ["!event", "!doctrine", "!console"]

However, this might not be enough for your needs, as some services might still use %kernel.debug% to determine when to log.

Gyp answered 21/7, 2022 at 11:3 Comment(1)
The original monolog.yaml is located at /vendor/shopware/core/Framework/Resources/config/packages/dev/monolog.yaml. Maybe you could add this to your code snippet for clarification.Northwesterly
R
2

Little optimization, for smaller log files. (based on the idea/solution from @dneustadt)

First optimization: This version removes the "deprecated ..." messages. In our case the log file reached about 10GB within two days with the deprecated messages. After filtering the deprecated messages the log file shrinked to 38 MB.

Second optimization is to split the file into daily files (type stream -> rotating_file)

{SHOPWARE_ROOT}/config/packages/prod/monolog.yaml

    monolog:
        channels:
            - 'deprecation'
        handlers:
            main:
    #            type: stream
    #            path: "%kernel.logs_dir%/%kernel.environment%.log"
                type: rotating_file
                path: "%kernel.logs_dir%/conf_pkgs_prod_monolog_yaml_MOD_%kernel.environment%.log"
                level: debug
                channels: ["!event","!doctrine","!deprecation"]
            # uncomment to get logging in your browser
            # you may have to allow bigger header sizes in your Web server configuration
            #firephp:
            #    type: firephp
            #    level: info
            #chromephp:
            #    type: chromephp
            #    level: info
            console:
                type:   console
                process_psr_3_messages: false
                channels: ["!event", "!doctrine", "!console"]´

@Moderators: Please be kind with me, if my Answer is not 100% perfect. If there is something I can do better, please comment and I will edit/update my solution.

Roseline answered 11/3 at 23:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.