Magento 2 – Log messages
This post is about log messages from your Magento 2 system. As a developer, you should use logging as often as possible and you also should know what they mean. You can only understand Magento 2, if you can also read its messages – they can tell you a lot about your running shop system. I give you a short introduction in common log messages.
Magento 2 – Log messages
Cache invalidate
A very common log message is the following one:
1 | [2017-12-13 13:28:53] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"tags":[],"mode":"all"},"is_exception":false} [] |
You will find such cache_invalidate messages in your debug.log file. If you are running your shop for a while, please don’t be worried! This is not an error! The system informs you about the following:
- a page was loaded in frontend and no cache was present – a cache for that site was generated the first time
- a cache interval ended (this cache is now invalid) and a new cache was generated
This messages are a bit confusing for you as developer. They flood your debug.log file. You can completely ignore it. There is an open ticket for Magento 2.3 development to add an admin switch to disable such messages. So you can mention, that this logging is currently a bug – or a unwanted feature.
Add of item with id was processed
This message in system.log is strange. It tells you, that an item with a given id was processed without any other information. After some time, your system.log is full of messages like this:
1 | [2017-12-13 13:30:39] main.INFO: Add of item with id Magento_Theme::design_config was processed [] [] |
Again, this is not an error. This message is logged in /vendor/magento/module-backend/Model/Menu.php and only informs you, that a menu item in adminhtml was added. I have absolutely no idea, why it is necessary to log this. It is very confusing….
Broken reference
The next confusing log message is a critical one. It looks like this:
1 | [2017-12-13 14:11:02] main.CRITICAL: Broken reference: the 'header' tries to reorder itself towards 'global.notices', but their parents are different: 'page.wrapper' and 'notices.wrapper' respectively. [] [] |
There are at least two reasons for such errors:
- “before” and “after” attributes for blocks, which have been moved to another parent. Often people forget to remove them and so your Magento 2 system complains about it. It is no serious problem. The messages are different for each Magento 2 version and there is an open ticket to do a clean up for legacy references.
- references are defined in your default.xml file which is applied to all pages, but only few of them using this layout. So on pages with different page layouts (different than 2columns-left.xml for example – there are missing references and lead to such errors. The problem: sometimes this is quite obvious to fix, but most of the time very confusing – so it is a good idea to ignore this error too.
Conclusion
Logging in Magento 2 is bad. Magento changed the way logs are written to a more global way to combine them to some log files with a logging system that supports different logging steps (debug, info, critical, …). This may be a good idea, but it lacks functionality to turn them off or better to turn them off per module. 3rd party module often don’t use this logging an efficient way, so logs grow fast and become useless. You may use an external program to filter log messages, but that is not a solution.
Standard log messages are often confusing developers and real important messages are often not seen. I hope in a future Magento version, this will be advanced to a more useful system.
Do you know other common log messages and its meaning? Please comment about your experiences…