<%@ page import="org.apache.commons.logging.Log" %> <%@ page import="org.apache.commons.logging.LogFactory" %>
Then you need to initialize the Log instance to do logging. As an example here I am going to log ADMIN_SERVICE_COOKIE in WSO2 Servers stored in in the session object.
<% String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); Log log = LogFactory.getLog(this.getClass()); log.info("Admin Cookie : " + cookie); %>Now the JSP page is ready for logging. But still there we need to add log4j properties in order to print logs in the carbon logs. You can do that by adding the following part to ${CARBON_HOME}/repository/conf/log4j.properties file.
log4j.logger.org.apache.jsp=INFOYou can define the logging granularity by changing INFO to DEBUG, WARNING, ERROR, FATAL, TRACE according to your requirement.
NOTE : You have to build the relevant bundle every time you change the JSP file/s.