Our company’s webapps currently generate log messages (via System.out), which are later analyzed automatically by other programs.
As a windows service, tomcat neatly produces logs to its “logs” directory, partitioned per day.
The problem is that in linux, everything goes to stdout, which may be redirected, is not split in daily files.
I tried an option at conf/context.xml: “<Context swallowOutput=true …”, but the output goes to catalina.out, unsplit, and commented with unconvenient lines.
In short: How to configure tomcat 6.0 in linux to handle System.out as it does as windows service.
Thanks in advance – Artejera
As far as I know, Tomcat on *NIX and win32 behave the same way: stdout is redirected to a file that is not rotated. When installing Tomcat as a service, did you use the Tomcat installer (which installs procrun) or did you use some other procedure to set up your service?
In your Linux environment, are you using bin/catalina.sh to launch Tomcat, or are you using jsvc or something else? Your options are different for each launch strategy.
If you consider using jsvc to launch Tomcat, you can send SIGUSR1 to the jsvc process in order to have it re-open the log files. That way, you can have a cron job or something similar execute the following:
That ought to re-open catalina.out with nothing in it and achieve the rotation you are looking for.
If you have to stick with bin/catalina.sh, then you can hack the file so that it pipes stdout into a logging service like chronolog, etc. which can rotate the log files for you.