You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Will England <wi...@mylanders.com> on 2001/04/17 17:59:07 UTC

Logging, server.xml and so on

Greetings!

After many days of searching and so on, I am still looking for information
on using the default logging built into Tomcat.

I am running Tomcat 3.2.1 under apache 1.3.12 on Solaris 2.7, with Java
1.3.

I have a servlet application set up that catches all the 'expected' errors
and logs them to text files, databases, etc.  This includes bad input,
missing or wrong parameters, and so on.

However, I still need to catch 'unexpected' errors at the top level and
log them to a standard log file.  Currently, I just am doing this:

} catch (Exception e) {
	e.printStacktrace();
}

This is fine for development; at least I can see on the console what
happened.  However, for production rollout, I'd sure like to be able to
have some real logs.

I have checked google, groups.google and the mailing list.  I do not want
to simply do a `tomcat start  >&2&1` log, I want actual java interfaces to
a logger object that can write to the log listed in server.xml.

My server.xml file currently has a log listed:

--- server.xml excerpt ---
    <Logger name="tc_log" 
            path="logs/tomcat.log"
            customOutput="yes" 
	    verbosityLevel="ERROR"/>
--- server.xml excerpt ---

However, this isn't working yet.

Also, in the <ContextManager> section of server.xml for my servlet, I see
this line:

<!-- ContextInterceptor className="org.apache.tomcat.context.LogEvents" /
-->

As you can see, it is commented out.  I have not found any references to
this in the FAQ or docs; of course it is entirely possible I have
overlooked this.  Uncommenting this did not change anything.

I have also tried to import org.apache.tomcat.logging.* into my servlet to
create a logger or TomcatLogger class, but the "package
org.apache.tomcat.logging does not exist".


SO, in a nutshell,  how do I get access to a logger object to log errors
and exceptions to the log referenced in the server.xml file?

Thanks in advance for any tips, pointers etc.

Will



-- 
  "If Al Gore invented the Internet, then I invented spellcheck!"
      Dan Quayle, quoted at the National Press Club, 8/3/1999 
                          will@mylanders.com 
  Recovery  : http://will.mylanders.com/         PCS:  316-371-FOAD 


Re: Logging, server.xml and so on

Posted by Will England <wi...@mylanders.com>.
On Tue, 17 Apr 2001, Sam Newman wrote:

> To get stuff into the log, you have to do the following (I'm assuming your
> in a servlet at the time!)
> 
> this.getServletContext().log("msg");
> or
> this.getServletContext().log("msg", exception);
> 
> Check the API docs for HttpServletContext for more details. As to how you
> can tailor this logging to reflect the debug level set for your context (ala
> log4j), I don't know. This works a treat in all my stuff anyway.


Damn.  Missed it by *that* much.  That's too simple.  Thank you.

Will


Re: Logging, server.xml and so on

Posted by Sam Newman <sa...@stamplets.com>.
To get stuff into the log, you have to do the following (I'm assuming your
in a servlet at the time!)

this.getServletContext().log("msg");

or

this.getServletContext().log("msg", exception);

Check the API docs for HttpServletContext for more details. As to how you
can tailor this logging to reflect the debug level set for your context (ala
log4j), I don't know. This works a treat in all my stuff anyway.

sam
----- Original Message -----
From: "Will England" <wi...@mylanders.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, April 17, 2001 4:59 PM
Subject: Logging, server.xml and so on


> Greetings!
>
> After many days of searching and so on, I am still looking for information
> on using the default logging built into Tomcat.
>
> I am running Tomcat 3.2.1 under apache 1.3.12 on Solaris 2.7, with Java
> 1.3.
>
> I have a servlet application set up that catches all the 'expected' errors
> and logs them to text files, databases, etc.  This includes bad input,
> missing or wrong parameters, and so on.
>
> However, I still need to catch 'unexpected' errors at the top level and
> log them to a standard log file.  Currently, I just am doing this:
>
<snip>