Tomcat Log configuration-----with log (i)

Source: Internet
Author: User


Reprint Address: http://blog.csdn.net/li_xiao_ming/article/details/21514637



problem

Each time Tomcat starts, the following log files are automatically produced in the logs directory, and a file of the corresponding date is generated daily, resulting in numerous log files:

Localhost.2012-07-05.txt

Catalina.2012-07-05.txt

Manager.2012-07-05.txt

Host-manager.2012-07-05.txt

Purpose

Tomcat logs are exported to the same file.

Modify Steps

Open the Tomcat directory conf\logging.properties, modify the following, all log output to the file at the beginning of Tomcat

1catalina.org.apache.juli.filehandler.level = FINE

1catalina.org.apache.juli.filehandler.directory = ${catalina.base}/logs

# 1catalina.org.apache.juli.filehandler.prefix = Catalina.

1catalina.org.apache.juli.filehandler.prefix = Tomcat.

2localhost.org.apache.juli.filehandler.level = FINE

2localhost.org.apache.juli.filehandler.directory = ${catalina.base}/logs

# 2localhost.org.apache.juli.filehandler.prefix = localhost.

2localhost.org.apache.juli.filehandler.prefix = Tomcat.

3manager.org.apache.juli.filehandler.level = FINE

3manager.org.apache.juli.filehandler.directory = ${catalina.base}/logs

# 3manager.org.apache.juli.filehandler.prefix = Manager.

3manager.org.apache.juli.filehandler.prefix = Tomcat.

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.

4host-manager.org.apache.juli.filehandler.prefix = Tomcat.

Tomcat Log Summary

1 Tomcat Log information is divided into two categories :

The first is the running log, which records some of the information running, especially some exception log information.

Second, access to log information, it records the access time, IP, access to information and other related information.

2 configuration of access logs

2.1 The default Tomcat does not record access logs, and the following methods enable Tomcat records to access logs

Edit the ${catalina}/conf/server.xml file. Note: ${catalina} is the Tomcat installation directory

Remove the following comments (<!---->).

<!--

<valve classname= "Org.apache.catalina.valves.AccessLogValve"

directory= "Logs" prefix= "Localhost_access_log." suffix= ". txt"

pattern= "Common" resolvehosts= "false"/>

-->

2.2 Configure Tomcat to write more detailed logs

The contents of the log output can be changed by modifying the pattern item in the 2.1 example.

The value can be: Common and combined, which correspond to the log output of the two preformatted formats as follows:

Common value:%h%l%u%t%r%s%b

Combined value:%h%l%u%t%r%s%b%{referer}i%{user-agent}i

Pattern can also be freely assembled according to need, such as pattern= "%h%l"

For the meaning of each fields field, refer to:

Access Log valve entries in http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html

3 Modifying the level of the Tomcat run log

3.1 Log types and Levels

Tomcat logs are grouped into the following 5 categories:

Catalina, localhost, manager, admin, Host-manager

The levels of each type of log are divided into 7 categories:

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

3.2 Logging Level setting method

Modify the content in the conf/logging.properties to set the level of a class of logs

Example:

Set the Catalina log level as: FINE

1catalina.org.apache.juli.filehandler.level = FINE

To disable the output of the Catalina log:

1catalina.org.apache.juli.filehandler.level = Off

Output Catalina All log messages are output:

1catalina.org.apache.juli.filehandler.level = All



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.