tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Chaffee <>
Subject Re: Stack Traces in standalone classes
Date Sat, 08 Jul 2000 13:15:34 GMT
> A "non-Tomcat context" in which logging already causes grief is Catalina.
> It does not utilize Tomcat's org.apache.tomcat.logging package itself
> (based on philosophical reasons -- there will be people who want all
> events from all components related to things like a particular virtual
> host or a particular application logged to the same place), and has to go
> to some pretty incredible pains to make a Tomcat-compatible logger
> available for Jasper.

That's a great idea.  It should (should!) be possible to make a
logging facility that works for (a) Tomcat, (b) Catalina, (c)
standalone classes, that satisfies the following:

- simple API, so programmers have no excuse for not using it
- predictable and consistent behavior
- prints to a log file, or to System.err (degrades gracefully)
- can defer to a superior (the point you made above)
- can specify verbosity level 
- expands nested exceptions 
- "debug" messages don't take up any CPU if debugging is turned off

The solution I've been slowly incorporating into the Tomcat tree has
most of the above; I'd love to discuss what would need to be done to
make it acceptable to Catalina.  Basically, you instantiate a helper
class that does all the work for you.  This would be a "mixin" in C++
but with Java there's a little extra typing, e.g.:

class Foo {
   Logger.Helper loghelper = new Logger.Helper("tc_log", "Foo");
     loghelper.log("Something happened");
     loghelper.log("Starting something", Logger.DEBUG);
     catch (IOException e) {
       loghelper.log("While doing something", e);

The "degrades gracefully" aspect should (!) make it acceptable to
include in classes like XmlMapper.  

I'm psyched that a common log API is in JSR
( )
-- but until that materializes, we can probably make a usable system

Alex Chaffee             
jGuru - Java News and FAQs
Creator of Gamelan       
Founder of Purple Technology
Curator of Stinky Art Collective

View raw message