tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: [somewhat OT] Clearing the catalina.out file
Date Fri, 14 Aug 2009 17:09:19 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Len,

On 8/14/2009 12:27 PM, Len Popp wrote:
> Testing it *properly* would take far longer than asking an expert

See my other post: testing is trivial.

> if it happens that some expert already knows the answer.

Fair enough. I guess my complaint is about the relative ease with which
this question can be answered. It's not like "we're getting some weird
behavior in our webapp/Tomcat and we've gotten lost reading the source
code of Tomcat... can an expect in Tomcat's internals give us some
help?". It's more like "I'm holding a pen in my hand. Can anyone explain
how to test if there's any ink in the reservoir?".

> For example, a simple "try it out" likely won't tell you what happens
> if Tomcat writes a log entry at the same moment when you're clearing
> the log file. Do you lose a log entry? Does the log file get cleared?

It's a race condition, which is why I suggested using logrotate to do
copytruncate. IMO Apache httpd does a better job because you can send a
signal to get it to re-open its log files. That allows you to do a
move-signal-reopen kind of thing, and no logs are lost. Tomcat chose to
go with the simplest thing that could possibly work: writing to stdout
and allowing the shell to perform redirection.

I have some suggestions to those who are concerned about catalina.out:

1. Just don't write to stdout. Tomcat produces very little output
   to stdout. Your web application can avoid doing it. Finally,
   Tomcat provides a "swallowOutput" option for webapps so that
   System.out and System.err end up writing to configurable loggers
   that can be redirected to other files (potentially rotated by
   smarter logging mechanisms than shell redirection).

2. Use a named pipe on the filesystem for catalina.out, plus a log
   watching facility designed to consume log messages in that way.

I'm sure there are other options as well.

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

iEYEARECAAYFAkqFmj4ACgkQ9CaO5/Lv0PCLzgCcCWnbbgs6JAOI2mf9mu3w6/FB
VHAAnRUo0eEiCBke/pfJJ8hcXDz5T1nK
=kEUo
-----END PGP SIGNATURE-----

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


Mime
View raw message