tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Gordon" <adam.gor...@readytalk.com>
Subject RE: Dynamic logging configuration updates in Tomcat
Date Mon, 15 Oct 2007 17:44:07 GMT
> I have no idea if Tomcat supports this -- the logging-related
> configuration directives in the docs should say if it is directly 
> supported.

I didn't see anything in the logging documentation that's indicated
either way whether or not this was supported.  The JVM theoretically
supports it with the LogManager.readConfiguration(...) method but as I
originally noted, there's a known bug in the JVM that causes new
configurations to not be loaded, however there is a work-around.

> Where do you do this? In your webapp or somewhere else?

We already have several servlet context listeners, so in the one that
initializes the web app (database, initializes static classes, etc...)
we add a thread to our thread pool whose sole job is to read the
logging.properties file and if it's changed within the last minute apply
those changes.  Originally, we constructed an InputStream from this file
and passed the stream to LogManager.readConfiguration(...) but as I've
mentioned (and even with the bug work-around) this only works for the
first couple of log file changes.  After the first few changes, it stops
working entirely in that no subsequent changes to the logging.properties
file is picked up short of changing the .level log level property.

> If you come up with something, consider logging a bug/enhancement  and
> submitting a patch. Suggestions with patches are usually given higher
> priority than those without patches ;)

I'd love to submit a patch, only I never found out where in Tomcat (if
it's even IN Tomcat) the problem is occurring.  My first test was
copying verbatim the code from LogManager that reads the properties from
the InputStream and iterates over the logging level properties applying
them to their respective loggers.  It worked consistently when I copied
it over, but not when I relied on LogManager to do it.  Once I got it
working consistently, I tweaked the code a little to maintain a mapping
of logger names to log levels so I could reset log levels for loggers
who had been removed from the logging.properties file during subsequent
changes.

--adam

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Thursday, October 11, 2007 12:39 PM
To: Tomcat Users List
Subject: Re: Dynamic logging configuration updates in Tomcat

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Adam,

Adam Gordon wrote:
> Wow, no one had any ideas as to what is going on?

I have no idea if Tomcat supports this -- the logging-related
configuration directives in the docs should say if it is directly
supported.

If you're using log4j, I know that there are tools you can use to modify
the in-memory configuration of the logging framework, but they won't be
persisted to the disk (and they don't allow you re-read the
configuration file AFAIK).

> Anyway.  We never figured out why Tomcat has an issue with this, but
we
> found a suitable workaround by basically doing what the LogHandler
does
> when it re-reads and refreshes the logging configuration - we take the
> new logging level values and apply them to their respective loggers.

Where do you do this? In your webapp or somewhere else?

> In fact, my first test was an exact copy of the LogHandler code and
the
> test worked (i.e., dynamic logging worked), whereas using the
LogHandler
> didn't....hmmmm.

If you come up with something, consider logging a bug/enhancement  and
submitting a patch. Suggestions with patches are usually given higher
priority than those without patches ;)

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHDm2x9CaO5/Lv0PARAhWXAJ4nVi21oqN7A99wtoZMtY1HzfUQNwCcDR8Q
ivOydqjYdN1xGwtd1WqrU8c=
=4Bp9
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message