问题描述
在tomcat 6.0.x中添加log4j [1]迫使tomcat在" catalina"文件中产生日志.但是,默认的catalina.out仍会产生和填充日志.所以,问题:
删除catalina.out文件(服务器运行时)是否安全? 如果是,可以将此删除添加到Tomcat启动脚本中吗?如果是,任何人都可以指出文件和所需的脚本吗? Tomcat是否有可能停止创建Catalina.out,因为它不再是Nessesary?
预先感谢人们!
推荐答案
tomcat将其Stdout和Stderr重定向到Catalina.out.因此,Direct Out/err Writes和Log4J ConsoleAppender消息将转到Catalina.out.请参阅 catalina.sh file "> catalina.sh文件有关详细信息.为了完全禁用它,您可以将stdout和stderr重定向到/dev/null设置catalina_out环境变量:
export CATALINA_OUT=/dev/null
但我建议禁用consoleappender,以降低catalina.out尺寸并定期监视它,以查找错误消息,这可能会绕过Log4j.
其他推荐答案
如果停止tomcat后删除catalina.out,它将创建一个新的catalina.out tomcat tomcat再次启动并且完全安全.
但是,如果您在运行tomcat时删除catalina.out,它将继续登录到catalina.out,该>已经删除了文件(tomcat> tomcat的引用),因此该空间不会是发行.因此,您需要重新启动tomcat dever以释放空间.不建议.
您可以尝试关注写入catalina.out:
- 找到和编辑文件:{catalina_base}/bin/catalina.sh
找到" catalina_out ",然后用" /dev/null "代替路径:
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out // Original Location CATALINA_OUT=/dev/null // replace path to /dev/null
其他推荐答案
是否有要删除catalina.out文件的原因?似乎这可能导致潜在缺少重要的事件消息.也许仅考虑设置
org.apache.catalina.level=INFO
否则,我想不出如果删除容器的功能会对容器的功能产生负面影响.在 *nix上安装其仍将其写入文件的文件描述符,该文件是从Inode(否则无法到达)的文件中的文件描述符,并且在Windows上,它不会让您删除它,因为容器将具有文件锁.
登录文档 - 快速rtfm只需能够从登录中删除处理程序.
问题描述
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?
Thanks in advance people!
推荐答案
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.
其他推荐答案
If the catalina.out is deleted after tomcat is stopped, it will create a new catalina.out once tomcat starts again and it is totally safe.
But if you remove the catalina.out while tomcat is running, it will keep on logging to catalina.out which is removed already (reference of the file is hold by the tomcat) hence the space will not be released. So you will need to restart the tomcat sever to release the space. It is not recommended.
You can try following to disable writing to catalina.out :
- Locate and Edit File: {CATALINA_BASE}/bin/catalina.sh
Locate "CATALINA_OUT" and replace the path with "/dev/null":
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out // Original Location CATALINA_OUT=/dev/null // replace path to /dev/null
其他推荐答案
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