Search code examples
javatomcat

How to clear catalina.out without disabling further logging?


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?


Solution

  • Easy as cake: echo > catalina.out. The file descriptor won't change and java can continue to write to that file.