Size Control of Tomcat output catalina. out
The default Log File catalina. out generated by Tomcat increases gradually over time, possibly reaching the G level. If the file is too large, we will not be able to use regular editing tools to view it, seriously affecting system maintenance. To solve this problem, we mainly consider Tomcat and code.
I. Code considerations
Tomcat outputs the catalina. out file. The main data sources are System. out and System. err. To reduce the pressure on log output and standardize code habits, you should avoid using System. out. println () and e. printStackTrace () During encoding ().
Ii. Tomcat configuration considerations
1. Tomcat uses log4j
This method is not discussed here.
2. Tomcat configuration
When deploying a service, you can add the swallowOutput attribute to the Context to reduce the output of console logs.
3. Use the cronolog tool for segmentation
A. Download The cronolog Tool
Official URL: http://cronolog.org/download/index.html
B. Compile and install cronolog
[TSP @ tsp-dev-webservice ~] $ Tar xvf cronolog-1.6.2.tar.gz
[TSP @ tsp-dev-webservice cronolog-1.6.2] $./configure
[TSP @ tsp-dev-webservice cronolog-1.6.2] $ make
[TSP @ tsp-dev-webservice cronolog-1.6.2] $ sudo make install
C. Modify the Tomcat STARTUP script catalina. sh.
A. Modify the output Log Path
Modify:
If [-z "$ CATALINA_OUT"]; then
CATALINA_OUT = "$ CATALINA_BASE"/logs/catalina. out
Fi
Is:
If [-z "$ CATALINA_OUT"]; then
CATALINA_OUT = "$ CATALINA_BASE"/logs/catalina. % Y-% m-% d. out
Fi
B. Delete the generated log file
Note:
Touch "$ CATALINA_OUT"
Is:
# Touch "$ CATALINA_OUT"
C. Modify Startup Script Parameters
Modify:
Org. apache. catalina. startup. Bootstrap "$ @" start \
> "$ CATALINA_OUT" 2> & 1 "&"
Is:
Org. apache. catalina. startup. Bootstrap "$ @" start 2> & 1 \
|/Usr/local/sbin/cronolog "$ CATALINA_OUT">/dev/null &
D. Restart Tomcat.
Tomcat output log files are separated successfully. The output log file format is catalina.2014-08-15.out.
Download resources:
------------------------------------------ Split line ------------------------------------------
Free in http://linux.bkjia.com/
The username and password are both www.bkjia.com
The specific download directory is in/June 25/June 25/Tomcat output catalina. out Size Control
For the download method, see
------------------------------------------ Split line ------------------------------------------
Load Balancing between Apache and multiple Tomcat clusters in Linux
Nginx Tomcat Cluster load balancing solution notes
Instance details Tomcat component installation + Nginx reverse proxy Tomcat + Apache use mod_jk and mod_proxy Reverse Proxy and load balancing
Deploy a log server using Rsyslog + LogAnalyzer + MySQL in CentOS 6.5
Build an Apache + Tomcat environment (JK deployment process)
Tomcat details: click here
Tomcat: click here
This article permanently updates the link address: