Log file rotation for Linux
Idea Logged
Would be good for the log files to auto-rotate .
The main culprit is catalina.out, which continually grows until I just blank it out. Before I started running "echo > /.../catalina.out" via cron it was about 750mb-1gb.
Other issues are with the catalina.[date].log, host-manager.[date].log, localhost.[date].log, & localhost_access_log.[date].log (this one is a particularly large group of .5-2mb files that are generated every day and don't seem to rotate at all).
Hey Andrew,
After failing to get this configured using some external articles, I've raised an enhancement to be reviewed by the devs. From what I can find, this will all be controlled via Tomcat, but maybe can ship with some pre-built scripts which can be copied to the relevant system folders to run.
I'll let you know once I hear more on this.
Thanks,David
Hey Andrew,
After failing to get this configured using some external articles, I've raised an enhancement to be reviewed by the devs. From what I can find, this will all be controlled via Tomcat, but maybe can ship with some pre-built scripts which can be copied to the relevant system folders to run.
I'll let you know once I hear more on this.
Thanks,David
Hi Andrew,
I know i's been a good few years (4 years) since this was logged, however progress has been made albeit late... With this I would like to give some feedback on this;
From what we can see It looks like Tomcat can rotate its own logs. There is a lot of documentation here albeit, it doesn't seem to mention rotation.
There is an example logging.properties file here, that has rotation enabled. Which should help with the issue in question.
With this there is also additional options for this... this is more of an advanced configuration for Tomcat that allows it to use log4j2 itself. This can be found here.
What next?
From the above information this then allows more ways or users to address this themselves. (I'm hoping this helps)
Let me know your thoughts on this.
Regards,
Mark
Hi Andrew,
I know i's been a good few years (4 years) since this was logged, however progress has been made albeit late... With this I would like to give some feedback on this;
From what we can see It looks like Tomcat can rotate its own logs. There is a lot of documentation here albeit, it doesn't seem to mention rotation.
There is an example logging.properties file here, that has rotation enabled. Which should help with the issue in question.
With this there is also additional options for this... this is more of an advanced configuration for Tomcat that allows it to use log4j2 itself. This can be found here.
What next?
From the above information this then allows more ways or users to address this themselves. (I'm hoping this helps)
Let me know your thoughts on this.
Regards,
Mark
Posting here for posterity, if anyone will stumble across this issue, a more on point solution
1. You need to create a custom configuration file (Yellowfin_Catalina) for Catalina.out under etc/logrotate.d as follows
a)daily means that the tool will attempt to rotate the logs on a daily basis. Other possible values are weekly and monthly.
rotate 10 indicates that only 10 rotated logs should be kept. Thus, the oldest file will be removed on the 11th subsequent run.
b)size=100M sets the minimum size for the rotation to take place to 100M. In other words, each log will not be rotated until it reaches 100MB.
c)compress are used to tell that all rotated logs, with the exception of the most recent one, should be compressed.
d)Copytruncate indicates that log file will copied to rotated log and main log will be truncated
e)Missingok tells logrotate to skip rotating and not give an error if the log file isn’t there
Last step is to schedule this in crontab and some example is shown below
That will take care of the log rotation. However that is goign to hide any abnormality because it will work just fine so in order to capture that, we also created a script to alert us when more than X amount of files are created,basically to alert when catalina files are growing uncontrollably
Hope this helps a bit
Posting here for posterity, if anyone will stumble across this issue, a more on point solution
1. You need to create a custom configuration file (Yellowfin_Catalina) for Catalina.out under etc/logrotate.d as follows
a)daily means that the tool will attempt to rotate the logs on a daily basis. Other possible values are weekly and monthly.
rotate 10 indicates that only 10 rotated logs should be kept. Thus, the oldest file will be removed on the 11th subsequent run.
b)size=100M sets the minimum size for the rotation to take place to 100M. In other words, each log will not be rotated until it reaches 100MB.
c)compress are used to tell that all rotated logs, with the exception of the most recent one, should be compressed.
d)Copytruncate indicates that log file will copied to rotated log and main log will be truncated
e)Missingok tells logrotate to skip rotating and not give an error if the log file isn’t there
Last step is to schedule this in crontab and some example is shown below
That will take care of the log rotation. However that is goign to hide any abnormality because it will work just fine so in order to capture that, we also created a script to alert us when more than X amount of files are created,basically to alert when catalina files are growing uncontrollably
Hope this helps a bit
Hi Stefan,
Some brilliant feedback there to help others who are affected by this. We appreciate the community spirit by letting us and other members know of this.
Have a great week ahead.
Regards,
Mark
Hi Stefan,
Some brilliant feedback there to help others who are affected by this. We appreciate the community spirit by letting us and other members know of this.
Have a great week ahead.
Regards,
Mark
Replies have been locked on this page!