Cronolog is a log polling (rotation) tool that can be used to store output log shards for Apache, Tomcat, Nginx and other Web servers on a daily or monthly basis. Cronolog reads the log contents from the standard input and writes them to a log file named in the specified format. When the date changes, Cronolog will close the previous log file and open a log file containing the new date. The Cronolog can be used to solve the problem that the Web server log files are growing and cannot be deleted at run time.
Cronolog Features:
Cronolog features Cronolog can log polling by month, day, or even by the hour, or you can configure the maximum value of each log file, which is automatically logged to the next log file when the file size reaches this maximum value.
The Cronolog stable version is 1.6.2, but this version has a disadvantage: when the log file size to 2G (2150726147 bytes), the Cronolog process becomes a zombie process, that is, the logs can not be written again, Cronolog 1.7 resolves this issue.
Download
Cronolog-1.7.0-beta.tar.gz
Installation
# tar zxvf cronolog-1.7.0-beta.tar.gz# cd cronolog-1.7.0#./configure--prefix=/usr/local/cronolog# make# make install
If you do not specify a--prefix path, Cronolog is installed by default on/usr/local/sbin/cronolog
Modify Apache Virtual Host Configuration
Edit the httpd.conf file to place the
[Email protected]~] #vim/etc/httpd/httpd.conf
The default log:
Customlog "Logs/access_log" combined
Modified to:
Customlog "| /usr/local/sbin/cronolog/logs/www/access_%y%m%d.log "combined
Where%y%m%d is the log file segmentation method, that is, "Month Day".
The key point is that the journal being polled must be an absolute path, not a relative path.
Old boy Learning notes:
650) this.width=650; "title=" cronolog.jpg "style=" Float:none "alt=" 0691aa1fa296bfd644e23a8aad7710bc.jpg-wh_ "src=" Https://s4.51cto.com/oss/201710/27/0691aa1fa296bfd644e23a8aad7710bc.jpg-wh_500x0-wm_3-wmp_4-s_2979902112.jpg "/ >
650) this.width=650, "title=" cronolog1.jpg "style=" Float:none; "alt=" 30f4d22d6d57a221200c8b21af91c834.jpg-wh_ "src= "Https://s5.51cto.com/oss/201710/27/30f4d22d6d57a221200c8b21af91c834.jpg-wh_500x0-wm_3-wmp_4-s_820911596.jpg"/ >
Modify the Tomcat configuration
Modify the catalina.sh in the Tomcat bin directory
# vim/usr/local/tomcat/bin/catalina.sh
Find the following code
catalina_out= "$CATALINA _base"/logs/catalina.outtouch "$CATALINA _out" if [ "$" = "-security" ] ; then if [ $have _tty -eq 1 ]; then echo "Using security manager" fi shift "$_runjava" "$LOGGING _config" $ logging_manager $JAVA _opts $CATALINA _opts - djava.endorsed.dirs= "$JAVA _endorsed_dirs" -classpath "$CLASSPATH" -djava.security.manager -djava.security.policy== "$ Catalina_base "/conf/catalina.policy -dcatalina.base=" $CATALINA _base " -dcatalina.home= "$CATALINA _home" -djava.io.tmpdir= "$CATALINA _tmpdir" org.apache.catalina.startup.bootstrap "[email protected]" start >> "$CATALINA _out" 2>&1 & else "$_runjava" "$LOGGING _config" $LOGGING _manager $JAVA _opts $CATALINA _opts -djava.endorsed.dirs= "$JAVA _endorsed_dirs" -classpath "$CLASSPATH" -dcatalina.base= "$CATALINA _base" -dcatalina.home= "$CATALINA _home" -djava.io.tmpdir= "$CATALINA _tmpdir" org.apache.catalina.startup.bootstrap "[email protected]" start >> "$CATALINA _out" 2>&1 & fi
Comment out the top touch "$CATALINA _out" as follows
#touch "$CATALINA _out"
The following two places
Org.apache.catalina.startup.Bootstrap "[email protected]" Start >> "$CATALINA _out" 2>&1 &
Revision changed to
Org.apache.catalina.startup.Bootstrap "[email protected]" Start 2>&1 | /usr/local/sbin/cronolog "$CATALINA _out" >>/dev/null 2>&1 &
Or
Org.apache.catalina.startup.Bootstrap "[email protected]" Start 2>&1 | /usr/local/cronolog/sbin/cronolog "$CATALINA _base"/logs/catalina.%y-%m-%d.out >>/dev/null &
Then reboot Tomcat to
This article is from "Operation and maintenance record Mei Ling" blog, please be sure to keep this source http://meiling.blog.51cto.com/6220221/1976745
Compiling and installing Cronolog Web Apache and Tomcat logs