Tomcat Close log catalina.out file will become larger and bigger, the stability of the system has caused some impact. Conf/logging.properties

Source: Internet
Author: User
Tags file handling tomcat
Generally after the deployment of Tomcat, run for a long time, the Catalina.out file will be more and more large, the stability of the system has caused a certain impact.
This section of the log information can be masked by modifying the Conf/logging.properties log profile.

1catalina.org.apache.juli.filehandler.level = WARNING
1catalina.org.apache.juli.filehandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.filehandler.prefix = Catalina.

Setting the level to warning can reduce the output of the log a lot, and of course it can be set to off and disabled directly.

The general log levels are:

SEVERE (highest value) > WARNING > INFO > CONFIG > FINE > Finer > FINEST (lowest value)

From:

http://rwl6813021.iteye.com/blog/752416

The log files generated by Tomcat under Linux are not processed as time and size under Windows,

Although the log file Catalina.2009-0x-0x.log type file is also generated, but the Catalina.out file is still larger, why it is growing, why it is growing, I do not explore.

Tomcat's official document, because it is a foreign language, I have not yet read the di;

Http://tomcat.apache.org/tomcat-6.0-doc/logging.html

It is said that some configuration can be modified to achieve, I hope the expert guidance, to an official solution;

It's not the way to grow, or the other way to get it done:

Method 1-Split the stream

Use the Cronolog tool to slice Tomcat's catalina.out log files

Cronolog a small tool for log slicing, whose home page is in http://cronolog.org/, we can also use it to slice Apache logs.

The specific method, you can go to Google, this method is the mainstream of web search results;

Method 2-Script flow

It's just a matter of big file handling, powerful bash to get it done;

Use Cron to back up the current catalina.out every day, and then empty his content;

The reference script is as follows:

#!/bin/sh

y= ' Date ' +%y "'

m= ' Date ' +%m "'

d= ' Date ' +%d "'

Cd/path/tomcat/logs

CP catalina.out Catalina.out. $y $m$d

echo > Catalina.out

Exit

Note whether the Cron service of the Linux system is started, is working properly, and where the script is stored (cause temporary secrecy)

Method 3-wretched stream

Open the Bin directory of the catalina.sh file, after all, is just a bash file,

Look up, catalina.out total three times;

Some screenshots:

Shift

Touch "$CATALINA _base"/logs/catalina.out

If ["$" = "-security"]; Then

echo "Using Security Manager"

Shift

"$_runjava" $JAVA _opts "$LOGGING _config" $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 "$@" Start \

>> "$CATALINA _base"/logs/catalina.out 2>&1 &

if [!-Z "$CATALINA _pid"]; Then

Echo $! > $CATALINA _pid

Fi

Else

"$_runjava" $JAVA _opts "$LOGGING _config" $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 "$@" Start \

>> "$CATALINA _base"/logs/catalina.out 2>&1 &

Personally, this is where you write catalina.out files; let him write to a different empty device.

Before modifying the original file to note the catalina.sh backup yo ~.

Modify the code in the above

>> "$CATALINA _base"/logs/catalina.out 2>&1 &

For

>>/dev/null 2>&1 &

Save, and then start Tomcat, the catalina.out has been empty for the time being.

This method is I think of myself, personally think more brave, not yet in the production environment tested. The virtual machine test is passed.

Method 4-flow of people

This method is actually the Linux system administrator manually remove, manual operation, referred to as "people";

It is best to stop Tomcat before deleting the service;

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.