BLOG

Want to take advantage of the Concrete5 logging functionality but don't know how? Here's a tutorial to explain how to use it.

concrete5-logging.jpg

How to log custom events in Concrete5 5.6

21st March 2016

The Concrete5 logging functionality is quite useful for keeping track of custom events in the CMS. It will natively record events like form submissions and exceptions, but it's really handy for keeping tabs on automated jobs or transactions on the website. Whatever you want to use it for, it's a really simple thing to add to your code.

    Log::addEntry('Message', 'Log Type');

The "log type" element (the second parameter) is the text that populates the report drop down type (where you can categorise logs by the different type). The first parameter (the message) is the text you'd want to log against that log type.

So if you were logging a certain sequence of events, you'd do something like:

    Log::addEntry('Product X added to basket by User ID: 1234', 'Product Purchasing');

    Log::addEntry('Payment page reached for User ID: 1234 on Transaction ID: abc123', 'Product Purchasing');
    
    Log::addEntry('Payment completed for User ID: 1234 on Transaction ID: abc123', 'Product Purchasing');

Those 3 events would be captured under the "Product Purchasing" log type, and this level of CMS-level tracking just makes life easier when you're trying to trace through any historical data.

It's as simple as making that static call to the Log::addEntry method. Easy but useful.

THINK THERE'S SOMETHING WE CAN TALK ABOUT?

Whether you want to discuss a piece of business, get advice on how to approach something in Concrete5, want my top Project Zomboid tips or just simply want to say hello, then please do. I'm not as anti-social as my status as a developer would suggest.

GET IN TOUCH

CONTACT

Image
LOCATION
Milton Keynes (near London)
Image
PHONE
Disclosed for business only
Image
E-MAIL
steven.york [at] seopher.com
Image
AVAILABILITY
Contact me to find out