On Tue, 2 Oct 2001, Deacon Marcus wrote:

> Date: Tue, 2 Oct 2001 18:24:07 +0200
> From: Deacon Marcus <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Logging - where?
>
> Hi,
> I seriuosly considering replacing standard logging with custom Log4J-MySQL,
> so I could have everything (Tomcat and WebApps) in one database.

It would be helpful in discussions like this to identify which version of
Tomcat you are interested in - they are quite a lot different.  The
answers below relate to Tomcat 4.

> 1) Where is logging done? Could you give me pointers to specific
> classes/methods I need to modify?

All loggers implement the org.apache.catalina.Logger interface, and the
standard implementations all live in the "org.apache.catalina.logger"
package.  Configuring which logger to use is done in server.xml file, by
using the "className" attribute of the <Logger> element.  Online docs are
at:

  http://jakarta.apache.org/tomcat/tomcat-4.0-doc/config/logger.html

> 2) Performance - is declaring SQL INSERTs as DELAYED or LOW_PRIORITY enough?
> Or making static per-db-url buffering and writing many (16-64?) records at
> once?

The current logger implementations are synchronous (they use the current
thread to write).  For a database logger, I'd definitely implement a
background thread that dequeues buffered messages and writes them out to
the database.

> 3) Is it possible to rewrite Tomcat's logging to enable pluggable logging
> engines? (Standard or Log4j)

There are two basic approaches that are feasible:

* Write an implementation of the "org.apache.catalina.Logger" interface
  that talks to Log4J.  This would be very easy, and would not require
  any modifications at all to existing code inside Tomcat.

* Modify Tomcat internals to use Log4J APIs instead of the Logger
  interface.  This is quite a lot more complicated (besides the tedious
  work required to change the code) because the hierarchical logging
  architecture inside Tomcat 4 does not really map very well to Log4Js
  concept of categories.  Ceki proposed an approach a while back on
  this list that has the virtue of at least working, but the concepts
  just don't match up very elegantly.

> 4) I saw suggestion to move to JDK 1.4 logging - _please_ if/when you decide
> to change logging, move to Log4j instead of this.

Because the calls to the logging code are scattered all throughout Tomcat,
this isn't even a feasible option until we're ready to declare JDK 1.4 the
minimum platform version required - and it's obviously too early to do
that.

> Greetings, deacon Marcus

Craig McClanahan

Reply via email to