'I have accidentally removed catalina.out and Tomcat doesn't recreate it

By default, Tomcat v7 was logging everything nicely to the catalina.out. When it got too big, I have removed it. Since then, the log file doesn't exist.

I have tried creating it manually, but it stays there untouched.



Solution 1:[1]

If the catalina.out is deleted after tomcat is stopped, it will create a new catalina.out once tomcat starts and writes to it. But in your case, since catalina.out was deleted while tomcat was running it is holding up the file reference and writing to the deleted file. You can get rid of this by restarting the tomcat server.

I assume you have created with root or another user which leads tomcat to not open it. Check ownership of the created file.

Use logrotate tool in Linux. It is a log managing command-line tool in Linux. This can rotate the log files under different conditions. Particularly, we can rotate log files on a fixed duration or if the file has grown to a certain size. You can click here for more info on this.

This will help you to automate the task of monitoring the log file size and rotate accordingly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Du-Lacoste