Size Control of Tomcat output Catalina. Out

Source: Internet
Author: User

Zookeeper

Resource URL: http://download.csdn.net/detail/attagain/7771065

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
[[Email protected] ~] $ Tar xvf cronolog-1.6.2.tar.gz
[[Email protected] cronolog-1.6.2] $./configure
[[Email protected] cronolog-1.6.2] $ make
[[Email protected] 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 "[email protected]" Start \
> "$ Catalina_out" 2> & 1 "&"
Is:
Org. Apache. Catalina. startup. Bootstrap "[email protected]" 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.