Tomcat Log shutdown and Setup

Source: Internet
Author: User
Tags system log log4j


The 3.1  log type and level

Tomcat logs are grouped into the following 5 categories:
Catalina, equivalent command-line output log
localhost, command line output Log Manager equivalent to localhost host
, Managed log
admin, 
Host-manager   should be virtual host

the level of each class of logs is divided into the following 7 kinds:
SEVERE (highest value) > WARNING > INFO > CONFIG > FINE > Finer > FINEST (lowest value)

3.2  Logging Level setting method

Tomcat generates files in the logs directory every day: Catalina.out, Catalina. Y-m-d.log, localhost. Y-m-d.log, manager. Y-m-d.log, Host-manager. Y-m-d.log

can change the way the log is generated by modifying the Conf\logging.properties file.

Example: Setting the level of a class of logs (note: The Catalina log outputs Catalina.) Y-m-d.log, different from catalina.out,catalina.out corresponding to Java.util.logging.ConsoleHandler configuration)

1    Tomcat Log Overview
Tomcat log information is divided into two categories:

One is a running log, it mainly records some of the information running, especially some exception error log information.
Two is to access the log information, it records the access time, IP, access to information and other related information.

2    Tomcat log configuration
2.1  Access log configuration

Default Tomcat does not record access logs, the following methods enable the Tomcat record access log

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

To 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


4 using LOG4J to log application logs or system logs
4.1 Using log4j to output verbose system log information to quickly diagnose startup failure

This example compensates for the problem of insufficient error information output when Tomcat starts an exception and uses commons-logging and log4j to output detailed log information.


Reference: http://blog.csdn.net/lk_cool/article/details/4561306/

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.