You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Cervenka, Tom" <TC...@uillinois.edu> on 2005/01/26 19:38:03 UTC

Tomcat belches out megabytes of white space during log rotation

I have this weird problem with an instance of tomcat 4.1.30 running on
Windows Server 2003. Tomcat output (log messages) is directed into
CATALINA_HOME/logs/catalina.out. Every 4 hours a little log rotation
script runs while tomcat is active. It zips catalina.out into an
archived logs folder and then truncates it. All this seems to work ok
and you end up with a small 1KB file. 

 

The problem is that the next log entry to catalina.out (from the next
request) is preceded by around 9MB of white space! After heaving this
load it settles down and writes log messages normally. Until the next
rotation that is. Then the same thing happens. At the first http request
to the server after catalina.out is trucated, boom, around 9 more MB of
white space is dumped into it. Not the exact same amount as before.
Actually, the amount has been going on for several months and the actual
amount of white space spew has been increasing. It started out around
4MB.

 

Has anyone seen this or something similar? I don't see this behavior on
Linux servers. The same script works fine. I feel I should also mention
that this server is configured to reply to SSL (https:) requests
although I'm not sure this is relevant info.

 

-Tom Cervenka


AW: Tomcat belches out megabytes of white space during log rotation

Posted by Steffen Heil <li...@steffen-heil.de>.
Hi

> I have this weird problem with an instance of tomcat 4.1.30 
> running on Windows Server 2003. Tomcat output (log messages) 
> is directed into CATALINA_HOME/logs/catalina.out. Every 4 
> hours a little log rotation script runs while tomcat is 
> active. It zips catalina.out into an archived logs folder and 
> then truncates it. All this seems to work ok and you end up 
> with a small 1KB file. 
> 
> The problem is that the next log entry to catalina.out (from the next
> request) is preceded by around 9MB of white space! After 
> heaving this load it settles down and writes log messages 
> normally. Until the next rotation that is. Then the same 
> thing happens. At the first http request to the server after 
> catalina.out is trucated, boom, around 9 more MB of white 
> space is dumped into it. Not the exact same amount as before.
> Actually, the amount has been going on for several months and 
> the actual amount of white space spew has been increasing. It 
> started out around 4MB.

You simply may not modify files, which are in use by other processes.
In fact, you may not modify the log at all, while the jvm has an open handle
on it.

I assume, that the whitespace is the result of truncating the log file.
I assume there are as many spaces in the new log as characters in the old
log.

Simple lesson: Don't do it.
Use another logging mechanism, which has build in rotation support.

I'd also assume the same problem to be present on linux.
It is not surprising that this does not work on windows, it is more
surprising that it works on linux.

Regards,
  Steffen