Ondrej Tokar
Ondrej Tokar

Reputation: 5070

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.

Upvotes: 3

Views: 3059

Answers (2)

Du-Lacoste
Du-Lacoste

Reputation: 12777

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.

Upvotes: 0

Vincent
Vincent

Reputation: 151

Catalina out file is created during the tomcat starting. The reference of the file is hold in the tomcat until the server is stopped. When you restart the server Catalina out will be created again

Upvotes: 9

Related Questions