Consent to the use of Personal Data and Cookies

This website needs your consent to use cookies in order to customize ads and content.

If you give us your consent, data may be shared with Google.

Disable Exceptions, such as not found, in Shopware

How to disable certain Exception error messages in Shopware, so that redundant messages do not show up in the log file.

65 views
d

By. Jacob

Edited: 2022-11-13 09:29

One thing I have been surprised by about Shopware, is the fact that I was getting strange error messages in my log about 404 HTTP responses, but technically these are not really errors.

For example, if a product or page is not found, then that is not really an error – it is just part of how the internet works when users request non-existent pages – you do not want to be notified about it in your error logs.

Shopware reports these as exceptions such as: NotFoundHttpException and ProductNotFoundException.

Luckily you can turn these irrelevant messages off in the config/packages/shopware.yaml file.

My shopware.yaml file now includes these rules:

shopware: 
    logger:
        exclude_exception:
            - Symfony\Component\HttpKernel\Exception\NotFoundHttpException
            - Shopware\Core\Content\Product\Exception\ProductNotFoundException
            - Shopware\Core\Content\Category\Exception\CategoryNotFoundException
            - Shopware\Storefront\Framework\Captcha\Exception\CaptchaInvalidException
            - Shopware\Core\Content\Product\SalesChannel\Exception\ProductSortingNotFoundException

There might be times where you want to investigate 404 errors, but mostly you can safely ignore them, because they are completely normal, and indeed, even expected.

Shopware Exceptions

It looks like quite a few Exceptions about expected situations are logged, in particular Shopware is quite aggressive about logging 404 Not Found messages, even though they are normal, expected, and not super relevant.

I think what we need to note before disabling specific exceptions is the following:

  1. Is the system working?
  2. Is anyone complaining that something does not work?

If you can answer yes and no to the above questions, and the Exception is not otherwise suspicious, then you can go ahead and ignore it, perhaps even disable it so it does not distract from actual errors in your shop.

Feel free to add your own exceptions in the comments!

ProductNotFoundException

Well, in my case, these seem to happen when a demo product is disabled, and as such I also do not want Shopware's log to be spammed with these messages. But, there might be cases where you do want to be notified about it, so be careful not to miss important messages. First verify the cause, then disable them in the log if you deem them redundant.

CategoryNotFoundException

I have investigated these a bit, and what I found is that typically Shopware will complain about a specific category ID. If I look up this ID in the category table of the database, I can tell that the category is inactive, which is probably the cause of the exception, and as such I think it is safe to disable logging for this too.

CaptchaInvalidException

I am not sure where this comes from, and in fact, I am not even sure we are using a CAPTCHA anywhere on our website. Maybe this comes from the contact form? It looks like another of those non-errors that are logged, and that is totally safe to disable.

ProductSortingNotFoundException

Yeah, another Not Found error. I stopped caring at this point and disabled it without further investigation.

It probably happens when a product sorting in the backend returns no results.

Tell us what you think:

  1. Undefined array key password doing installation of Shopware using the web installer.
  2. How SEO URLs work in Shopware, and how to customize them.
  3. Running messenger:consume workers with a time limit can be useful, but you should also not set it too low.
  4. If shopware is stuck in maintenance mode, make sure to delete the update fulder and disable maintenance mode manually.

More in: Shopware