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. In case 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.
Delete/ Move catalina.out
when tomcat
server is stopped will not have any problem at all.
But in critical applications running on tomcat
used by public, this won`t be a good solution since there will be a downtime.
Actually you can clear the log of catalina.out
file without stopping tomcat with the command below.
sudo cat /dev/null > /opt/tomcat/apache-tomcat-9.0.37/logs/catalina.out
To keep catalina.out
smaller and get rid of older logs, either one of the following ways can be used:
You could use the above Linux
command and add it to a CronScheduler
to run daily/ weekly/ monthly or yearly as preferred.
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.