2
votes

Adding log4j [1] in tomcat 6.0.x forces tomcat to produce logs in "catalina" file. However, the default catalina.out is still produced and populated with logs. So, questions:

Is it safe to delete catalina.out file (while server running)? If yes, could this deletion be added to tomcat startup script? If yes, could anyone please point out the file and the required script? Is it possible for tomcat to stop createing the catalina.out, since it is not nessesary anymore?

  1. http://tomcat.apache.org/tomcat-6.0-doc/logging.html

Thanks in advance people!

2

2 Answers

6
votes

Tomcat redirects its stdout and stderr to catalina.out. So direct out/err writes and log4j ConsoleAppender messages will go to catalina.out. See catalina.sh file for details. To disable it completely you can redirect stdout and stderr to /dev/null setting CATALINA_OUT environment variable:

export CATALINA_OUT=/dev/null

But I recommend to disable ConsoleAppender instead to reduce catalina.out size and monitor it periodically looking for error messages, that may go to stdout bypassing log4j.

-1
votes

Is there a reason you'd want to delete the catalina.out file? It seems like it might lead to potentially missing important event messages. Perhaps consider just setting

org.apache.catalina.level=INFO

Otherwise I can't think of a reason that it would negatively impact the functionality of the container if you deleted it. On a *nix install its still writing to the file descriptor of a file that is diconnected from an inode(so otherwise unreachable) and on windows it won't let you delete it because the container will have a file lock.

logging docs - a quick rtfm and it looks like you should just be able to remove the handlers from logging.properties to discontinue producing this file