如何在不禁用进一步日志记录的情况下清除 catalina.out? [英] How to clear catalina.out without disabling further logging?
问题描述
每隔一段时间我们的 catalina.out 文件就会变得非常大(是的,我将在我的应用程序中实现 slf4j 和 logback 以防止将来发生这种情况).但是现在,当我去循环日志时,我将 catalina.out 复制到 catalina.{date} 并执行 cat/dev/null >catalina.out
.问题是,在我这样做之后,tomcat 将不再捕获更多日志,直到第二天早上重新启动 tomcat,这并不理想.为什么会发生这种情况?有没有办法避免它?
Every once in a while our catalina.out file gets very very large (yes, I will be implementing slf4j and logback in my applications to prevent this in the future). But for now, when I go to cycle the logs, I copy catalina.out to catalina.{date} and execute cat /dev/null > catalina.out
. The problem is, tomcat will capture no further logs after I do that, until tomcat is restarted the next morning, and this is not ideal. Why does this happen? And is there a way to avoid it?
推荐答案
简单易行:echo >catalina.out
.文件描述符不会改变,java
可以继续写入该文件.
Easy as cake: echo > catalina.out
. The file descriptor won't change and java
can continue to write to that file.
这篇关于如何在不禁用进一步日志记录的情况下清除 catalina.out?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!