Link to home
Start Free TrialLog in
Avatar of HycelTaylor
HycelTaylor

asked on

Servlet Logging in Tomcat

I want to log information about my servlet each time it is called.  I'm not sure how to set this up with Tomcat.  As best I can tell, I need to add the following element,

      <!-- Global logger unless overridden at lower levels -->
      <Logger className="org.apache.catalina.logger.FileLogger"
              prefix="servlet." suffix=".log" timestamp="true" />

somewhere in my sever.xml file.  I got this information from the following address: http://minaret.biz/tips/tomcatLogging.html.  If this is true, then where exactly should in place this element in server.xml?

This has me a little confused as it conflicts with the information I read at, http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/rzaie/rzaietomcat.htm.  I believe it implies that a log file called, servlet.log, will automatically be created.

Which is true?  Is either true?  Or are they both true but different approaches?

Lastly, once I've told Tomcat about logging my servlet, will do some automatic logging of sevlet information or will have to tell it exactly what to log?  And if I tell it what to log, do I just use the following method?

httpServletRequest.getSession().getServletContext().log("Some message");

Thank you, in advance, for help on this issue.
ASKER CERTIFIED SOLUTION
Avatar of ramazanyich
ramazanyich
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial