Good news for me! In an XPage application I wanted to provide an error logging function and preferably to OpenLog. I had problems with implementing the previous version of OpenLog logger but yesterday a new version is released on OpenNTF which took away that pain.
The OpenLog logger has some powerful features:
- It can be used in your managed beans and other Java classes.
- It can be used directly from SSJS with as little as openLogBean.addError(e,this);.
- From SSJS all caught errors on the page are logged out together, at the end of the request.
- Only two method names are used from SSJS, one to add an error, one to add an event, making it easy to pick up
- From SSJS you only need to pass the information you wish. There is no need to pass nulls or empty strings.
- From SSJS only one unique error per component is logged, regardless of how many times the error is encountered during the refresh lifecycle.
- In SSJS, if you use a custom error page, uncaught errors will also be logged.
- Uncaught errors will be logged for the page the error occurs on, not your custom error page.
- You can define the OpenLog path and a variety of other variables without needing to change the code.
- The functionality and code are available as an OSGi plugin (the best practice approach) but can also be included in individual NSFs.
Custom Runtime Error Page
In case you want to implement such functionality then I recommend you also take a look at how to define a custom run time error page. In my project I am using Bootstrap for UI look & feel, so I followed the steps Erick McCormick provides in this blog post.
In Erick’s post you will find that he uses Google’s code-prettify project. A nice feature is to ability to set a skin for the error message box. There are plenty of color themes available for the prettify project but if you use Bootstrap like I do you could try this theme.
A big thank you to the OpenLog logger project members and Erick!