Logging in concrete5

Logging in concrete5

Logging can be a life saver when working with concrete5. It's really simple too!

Snippet by Ollie / / Comments / Difficulty 
Logging in concrete5

When building in concrete5, sometimes it's hard to understand what is happening at particular points in your code's execution. This is especially true when working with Ajax since the executed code isn't even running in your browser. For these reasons and others, logging variables or entire sections of output so you can inspect them once execution has completed is a sensible thing to do during development.

concrete5 has an event log in the dashboard. Typically you'll find exceptions and email sending events logged there, but you can add your own entries to this log using the concrete5 log library and this simple code:

Log::addEntry($logEntry, $logType = null);

In the above example, $logEntry is the content to be logged, and $logType is an optional parameter which will allow you to filter the logs to inspect just entries of this type.

Join the conversation

comments powered by Disqus