How can I install cronolog in Tomcat for daily log rotate?
Question
When i wanted to lotate log daily, I was editing catalina.sh in other to redirect log to cronolog.
I think it is bad solution because catalina.sh file is executable shell file.
Can I config it using editing properties or any files in conf directory ?
Is there another good solution?
new:
org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \ | cronolog "$CATALINA_BASE"/logs/catalina. %Y-%m-%d.out >> /dev/null &
old:
org.apache.catalina.startup.Bootstrap "$@" start \ >> "$CATALINA_BASE"/logs/catalina.out 2>&1 &
Solution
Why not use a proper logging framework instead of System.out? You have at least three at your disposal:
- java.util.logging and use the RollingFileHandler from http://www.x4juli.org/
- Log4j and use DailyRollingFileAppender
- Logback and use RollingFileAppender
Using any of these you will be able to control what you log (using levels - debug, info, warn, error), where you log (turn loggers on and off) and log into different targets - files, db, mail, jms etc.
OTHER TIPS
David Rabinowitz makes a good point, but to answer your question, your use of cronolog is fine.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow