You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Prastein, Rebeccah H" <Re...@questdiagnostics.com> on 2008/11/25 21:34:44 UTC

log4j FileAppenders not flushing

I'm hoping someone here can help me with this; I've searched all over
the web, and any references to FileAppenders not flushing in the log4j
lists get the response, "not a log4j problem, must be your application."

I have a simple 3-page Spring 2.5 Spring MVC application running under
Tomcat 5.5.  I'm using log4j 1.2.14 for web application logging.  Rather
than configure log4j from a properties file or an xml file, I'm
configuring it manually in a servlet that allows me to reconfigure it in
real time using http commands.  I create two RollingFileAppenders: one
for the rootLogger containing debugging information, and one for a
separate requestLogger that shows input to and output from the
application.

Every time I send a query to the Spring MVC applciation, there should be
a series of log entries in the debug log, and one in the request log.
What I find is that sometimes the log entries show up right away, but
more often, one or the other log will show nothing until I have queried
3, 4, or up to 8 times - and then, all of the backlogged log entries
appear.  At first, I thought maybe my real-time configuration changes
were causing I/O blocking, because I first noticed it when I was testing
that feature.  But, even if I completely leave everything as it was on
web application startup, this happens.  I tried playing with the
settings on the RollingFileAppenders, even though by default IO
buffering is supposed to be off and immediateFlush is supposed to be
true.  I added a System.out.println() following one of my logging call
statements, to tell me what the immediateFlush value is for the logger
that was just written to, and it's "true," as expected.  But it's NOT
flushing.

Is there something in Tomcat that is intercepting these log4j calls and
causing this buffering behavior?  Is there some way to configure it?

Thanks for any help,

Rebeccah
------------------------------------------
The contents of this message, together with any attachments, are
intended only for the use of the person(s) to which they are
addressed and may contain confidential and/or privileged
information. Further, any medical information herein is
confidential and protected by law. It is unlawful for unauthorized
persons to use, review, copy, disclose, or disseminate confidential
medical information. If you are not the intended recipient,
immediately advise the sender and delete this message and any
attachments. Any distribution, or copying of this message, or any
attachment, is prohibited.

---------------------------------------------------------------------
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


Re: [OT] log4j FileAppenders not flushing

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rebeccah,

Prastein, Rebeccah H wrote:
> I'm hoping someone here can help me with this; I've searched all over
> the web, and any references to FileAppenders not flushing in the log4j
> lists get the response, "not a log4j problem, must be your application."

As much as I hate to say this, you should really go over to the log4j
list and ask them. They may say it's your application, but they may also
give you some tips on how it could be your application. I'm pretty
familiar with log4j and I've never seen logging statements swallowed.
sometimes they take a few seconds to actually get flushed to the log
file, but I've never seen them stay in a buffer forever.

> Is there something in Tomcat that is intercepting these log4j calls and
> causing this buffering behavior?  Is there some way to configure it?

Have you specifically configured Tomcat to use log4j for logging? If
not, then Tomcat is probably not interfering with your logging.

- -chris

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

iEYEARECAAYFAkk0W6oACgkQ9CaO5/Lv0PDR3ACfQHtSIjnpAe4n+L6q+RO/Sx6t
PagAn2Yl95VquJrLbATbou353njFURfT
=lnSW
-----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