Tomcat 6 log4j - linux - safely remove catalina.out

老子叫甜甜 提交于 2019-12-10 10:39:10

问题


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!


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/9636805/tomcat-6-log4j-linux-safely-remove-catalina-out

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!