Tomcat as NT Service overwrites log files
843840Dec 9 2002 — edited Sep 1 2008We are deploying Tomcat as an NT Service. We use the -out and -err options to log any System.out and System.err messages to a file. The problem is that if the server goes down and restarts itself, the log files are lost when the service restarts. Does anyone know how tomcat.exe can append to instead of overwrite these files?
Here is our command to install the Service:
"%CATALINA_HOME%\bin\tomcat.exe" -install "Fetch Tomcat Instance" "%JAVA_HOME%\jre\bin\server\jvm.dll" -Xms128M -Xmx256M -Djava.class.path="%CATALINA_HOME%\bin\bootstrap.jar" -Dcatalina.home="%CATALINA_HOME%" -Dcatalina.base="%CATALINA_BASE%" -start org.apache.catalina.startup.BootstrapService -params start -config "%MY_APP_SERVERXML_FILE%" -nonaming -stop org.apache.catalina.startup.BootstrapService -params stop -out "%MY_APP_HOME%\logs\stdout.log" -err "%MY_APP_HOME%\logs\stderr.log" -current .
Ideally, we would log all messages to a Tomcat Logger and not have this issue, but we don't have complete control over all of the code we are executing (some legacy code that would be expensive to rewrite), and this legacy code makes calls to System.out and System.err.
It seems that the "swallowOutput" attribute on the Context element would be our ideal solution, but we couldn't get it to work. It seeme d that output continued to be written to the stdout and stderr regardless of the setting of this attribute.