You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Steve Kirk <to...@web-startup.co.uk> on 2005/05/26 15:17:42 UTC

Logging to two logfiles by classes instantiated by init

I have always used 2 ways of logging.  Mainly I use java.util.logging
classes, including a custom Formatter that I wrote myself.  I do not use
log4j.  When my webapp first starts, the init() method of my own custom
Invoker servlet loads the config for my main logging code is loaded from
web.xml using getInitParameter(), so if for any reason that config is bad,
or some other exception happens during init(), I use the bogstandard
javax.servlet.GenericServlet#log() method to log any problems to TC's own
loggers.  All of this works fine.

Once initialised, my main logging code works by providing a static method
that any servlet in the webapp inherits.

Now, here is the weird thing.  When Invoker.writeToLog is called by a class
that was instantiated during Invoker#init(), it writes the log message to
both its own logfile and the TC stdout log.  These two files have quite
different formatters, and the message appears in the appropriate format in
each file.  When double-logging happens, the TC log clearly shows that
Invoker.writeToLog was the calling method, so it's not just that my code is
calling both methods.  Servlets and classes loaded/instantiated later log
correctly to my main log only.

Can anyone suggest what might be causing this please?  More details on setup
below.

I have been running TC5.0.x on JDK1.4.x for about a year, and previous
versions before that.  I just upgraded to TC5.5.9/jdk1.5.0_02.  Have made
the config changes required and it all works swimmingly.  Only one problem
persists, a small logging issue, which in fact was there before, but I
ignored it.  Basically some of my log statements get written to two files at
the same time.

However, given that logging has moved on a bit in 5.5, this is a chance to
clean things up, so I have decided to take a look at it.  I have removed the
<Logger> that used to be in conf/server.xml in TC5.0.  I therefore have the
bogstandard logging that ships in a standard 5.5 TC install.  (I do have a
FastCommonAccessLogValve and a RequestDumperValve configured but I'm
assuming that those are separate issues).



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org