How we can write plugin error logs?

I read the following from

“The error messages and hints of the plugin may only be written to the plugin-log in the log folder of Shopware ( /var/log/ ). The method $logger must be used for this. Never write plugin exceptions into the Shopware core.log or outside the Shopware log folder. This ensures that the log file can never be accessed via URL”

https://docs.shopware.com/en/plugin-standard-for-community-store.

How we can implement this?

Are there any free plugins contains this feature?

Or any Shopware documentation is for this feature?

Please help me.

Hey,

there is dedicated logger service for plugins. It’s ID in the DI container is “pluginlogger”. Here is an example: https://github.com/shopwareLabs/SwagPaymentPayPalUnified/blob/master/Resources/services/services.xml#L119
Since Shopware 5.6 you are even able to create your own plugin specific logger: Shopware 5 upgrade guide

I will adjust the article to make it more clear, what should be used.

Best regards from Schöppingen

cool Michael Telgmann

1 Like