So here it goes.
1) In a directory which the user you are running tomcat can write create a file called logadm.conf with the following content (assuming tomcat is in the /opt/tomcat/ folder):
/opt/tomcat/logs/catalina.out -C 15 -c -t '/opt/tomcat/logs/$basename.%Y-%m-%d'
2) Create a cron job for the same user (assuming you saved the configuration in /opt/tomcat/logrotate):
You can add the cron entry to the user that is running tomcat in the following way:
export EDITOR=vi
crontab -e
add the line:
0 0 * * * logadm -f /opt/tomcat/logrotate/logadm.conf
This will make it run every midnight of everyday.
- Explanation on the parameters of logadm
This command, that exists since the solaris 9, will rotate the catalina.out, will rotate the specified log file. The -C tells how many old copies of the files will be kept. The -c is the secret here. It will truncate the log file instead of renaming. This way tomcat keeps the handle to the file and can keep logging. -t uses a template to create the rotated files. Without that it will just append a .1, .2, etc.
You should run it manually before adding to your crontab.
That should be all!!!!
3 comments:
¡ obrigado !
Thansk a lot for this information, I didn't know "logadm" existance in solaris, now I think this will save my life.
1) In a directory which the user you are running tomcat can write create a file called logadm.conf with the following content (assuming tomcat is in the /opt/tomcat/ folder):
/opt/tomcat/logs/catalina.out -C 15 -c -t '/opt/tomcat/logs/$basename.%Y-%m-%d'
if I want to put log rotated
can I change '/opt/tomcat/logs/$basename.%Y-%m-%d' become '/data/logs/$basename.%Y-%m-%d'
because my Tomcat_HOMe less fre space
Hi,
What do you mean with $basename? Is my assumption right:
basename=catalina_rotate
Kind regards
Mehrdad
Post a Comment