debug jsp loggers

Debugging objects in JSP with jahia logs

Question

I want to debug some JSP objects in my view to troubleshoot an issue. How can I log these objects in jahia logs?

Answer

One easy way to log JSP objects in jahia logs is using the utilityLib.

To do so add the following declaration in your JSP:

<%-- ADD THE FOLLOWING TAGLIB DECLARATION --%>
<%@ taglib prefix="utility" uri="http://www.jahia.org/tags/utilityLib" %>

And then you can debug your JSP objects using the logger tag from utilityLib:

<%-- TO LOG INFORMATION IN JAHIA LOGS ../tomcat/logs/jahia.log --%>
<utility:logger level="INFO" value="JSP DEBUG - Content of node property someProperty is : ${currentNode.properties['someProperty'].string}"/>

Then you should see a log similar to that in your jahia logs, usually under <webApplicationDirectory>/logs/jahia.log :

2021-01-15 12:19:10,579: INFO  [Logger] - JSP DEBUG - Content of node property someProperty is : someValue