Step One:
Logs will produce Catalina.out, hostxxx, Mangerxxxxxx, host-mangerxxxxx, and other logs, recommended the newly installed Tomcat WebApps the following
Docs examples Host-manger manger and so on deleted, Root also emptied into its own function page and so on. Although the above applications have been removed, but the logs below will still produce corresponding log files (in the form of a day); Modify the Conf/logging.properties file to annotate the following places:
#2localhost. Org.apache.juli.FileHandler.level = FINE
#2localhost. org.apache.juli.FileHandler.directory = ${catalina.base}/logs
#2localhost. Org.apache.juli.FileHandler.prefix = localhost.
#3manager. Org.apache.juli.FileHandler.level = FINE
#3manager. org.apache.juli.FileHandler.directory = ${catalina.base}/logs
#3manager. Org.apache.juli.FileHandler.prefix = Manager.
#4host-manager.org.apache.juli.filehandler.level = FINE
#4host-manager.org.apache.juli.filehandler.directory = ${catalina.base}/logs
#4host-manager.org.apache.juli.filehandler.prefix = Host-manager.
The logs below still produces only catalina.out but catalina.out will always accumulate in a file, which can be cut by day using the following methods:
Step Two:
To modify the log level:
1catalina.org.apache.juli.filehandler.level = INFO
1catalina.org.apache.juli.filehandler.level = INFO
Step Three:
workaround, use Cronolog for log cutting, it is said that Cronolog is a small tool for cutting logs, you can cut many kinds of log files, have time to try. The following are the specific practices:
1. Download (latest Version)
# wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
2. Decompression
# tar zxvf cronolog-1.6.2.tar.gz
3. Enter the directory where the Cronolog installation files are located
# CD cronolog-1.6.2
4. Run the installation
#./configure
# make
# make install
5. Check the directory where the Cronolog is installed (verify the installation is successful)
# which Cronolog
typically shown as:/usr/local/sbin/cronolog
6. Go to the Tomcat bin directory, Open the catalina.sh file to find the related lines of Tomcat startup, or you can directly find the catalina.out, generally we modify the contents of the following line (because we generally do not run under-security conditions),
Else
"$_runjava" $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 _base"/logs/catalina.out 2>&1 &
if [!-Z "$CATALINA _pid"]; Then
echo $! > $CATALINA _pid
fi
fi
Modify
org.apache.catalina.startup.Bootstrap "[email protected]" start \
>> "$CATALINA _base"/logs/catalina.out 2>&1 &
to be
org.apache.catalina.startup.Bootstrap "[email protected]" Start 2>&1 \
|/usr/local/sbin/cronolog "$CATALINA _base"/logs/catalina.%y-%m-%d.out >>/dev/null &
at the same time, there is a row
Touch "$CATALINA _base"/logs/catalina.out
can be commented out, after the completion of the restart Tomcat can be, in the logs directory can see the Catalina.2009-02-18.out log, is generated by the day.
7. Write a script to add a weekly schedule to delete all log files that are more than seven days away
Reference URL:
http://cmjcmj8080.iteye.com/blog/847619
http://blog.163.com/[email protected]/blog/static/17185153620134695718916/
Tomcat log too big optimization ideas and steps