How to redirect all shopware logs (monolog) including plugins (bundles) to single target like a file or stderr

40 views Asked by At

how can I redirect all logs, including all plugins (bundles) to single target like a file or stderr. I work with Shopware version 6.4.20.2 In my plugin https://github.com/ditegra-GmbH/DigaShopwareCacheHelper I'm using LoggerFactory to create and then inject a logger and use this to log different stuff.

symfony/monolog-bundle: "3.6.0" Symfony 5.4

<service id="DigaShopwareCacheHelper\Util\Logger" class="Monolog\Logger">
   <factory service="Shopware\Core\Framework\Log\LoggerFactory" method="createRotating"/>
   <argument type="string">diga_cache_helper</argument>
</service>

this is my /var/www/html/config/packages/dev/monolog.yaml configuration

monolog:
    handlers:
        main:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%_RIS-TEST.log"
            level: debug
            channels: ["!event","!doctrine"]

My expectation is to see all logs in this single file now, but my Plugin CacheHelper: still logs in his own file var/log/diga_cache_helper_dev-2024-03-29.log.

Is there a way to redirect all logs via monolog config to single file / stderr?

I could also refactor my plugin to provide a configurationso I log to the main logger instead of diga_cache_helper, but it would be greate to do it via monolog config as on a cluster setup I would like to be able to catch all logs.

0

There are 0 answers