Best practise advise on logging and error handling

A few issues has popped up as of late, with how apps are developed, that affect the performance of XP installations. If you develop apps for XP, please take note about these common issues that can affect the performance of your apps.


We’ve noticed a lot of use of logging in production environments on our cloud platform and when visiting clients. Using the in your Enonic XP app will add to the XP log file, which is not good in production. Especially not when logging huge amounts of JSON. The files easily add up to many GBs of data over a few hours on sites with heavy traffic.

Make sure to update your own routines for deploying to production and get rid of all those logs! Using log.debug is recommended.

Be aware that the log-function in lib-util also uses in the background, so don’t let those lines go into production either.

Complicated error templates

When creating error handling in XP it is strongly advised to make these as simple as possible. The more controller code needed, the more prone are you for error-loops (errors inside the error handler) and slower performance in general. There are easily thousands of useless requests being made to arbitrary URLs on your website daily, and these will fire the 404 error handler. So if that error handler is complex, it will affect the entire server. Stay away from doing http requests in your 404 page, doing complex JS (nested loops), or redirects.