[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Servlet Logging in Tomcat

Posted on 2005-05-13
1
Medium Priority
?
1,062 Views
Last Modified: 2006-11-18
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.
0
Comment
Question by:HycelTaylor
1 Comment
 
LVL 19

Accepted Solution

by:
ramazanyich earned 1000 total points
ID: 13998512
with evolution of tomcat (and jdk) logging mechanisms in tomcat were also changing. Both links which you provided are correct, but they describe diffferent versions of tomcat.
It is better consult in that case original documentation of tomcat vor your version.
for tomcat 5.5:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/logging.html
for tomcat 5.0:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/logger.html
for tomcat 4.1
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/logger.html


in any case your servlet can be the same: you will use getServletContext().log() api call.
it is only different way of configuration.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month18 days, 2 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question