Hi,
Sometimes it is helpful have log statements in JSPS. Unfortunately if we have lot of business logic embedded in JSP’s. It is better to have log statements.
To add log statement in JSP
• Import logger
o <%@page import="org.apache.log4j.Logger"%>
• Provide the logger name, FQN name of the JSP
o private static final Logger logger = Logger.getLogger("portlet.ext.watching_portlet.view.jsp");
• Add the log statements as mentioned in the guide lines
o logger.warn("Unable to find thread associated to subscription");
Best practice:
Please don’t rely on toString method to get the exception stack trace.
Poor: logger.warn("Unable to find thread associated to subscription"+e);
Good: logger.warn("Unable to find thread associated to subscription",e);//exception stack trace will be logged, even if api doesn’t override the toString method
Sunday, July 11, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment