Tomcat log system details

Source: Internet
Author: User

Overall: log files related to Tomcat
The log file of the Cataline engine. The file name is catalina. Date. log.
The log generated by the internal code in Tomcat. The file name is localhost. date. log (exception of internal error in jsp page, org. apache. jasper. runtime. httpJspBase. if the service class is thrown out, the log information is in this file !)
Default manager application log in Tomcat, file name manager. Date. log
Logs output by the console are redirected to catalina. out by default in Linux.
Access Log (Servlet. xml configuration)
Logs redirected by the application through log4j. properties: $ {catalina. base}/logs/probe. log
JULI: log file name corresponding to org. apache. juli. FileHandler: {prefix}. {date}. {suffix} default juli. date. log

The following three types of logs can be used for Web applications under Tomcat:
Use java. util. logging.
Use the log javax. servlet. ServletContext. log (...) defined in the Java Servlets specification (...)
Use other log frameworks, such as log4j

Servlet logs used in different Web applications (or logs provided by the log framework) are independent of each other (this is related TO Tomcat class loader. For more information, see HOW-
). If the Web application uses java. util. logging logs are not independent of each other because of java. util. logging is loaded by Bootstrap ClassLoader in the JAVA system, so it is shared among various Web applications!

Log configuration file used by Tomcat: $ CATALINA_BASE/conf/logging. properties
By default, the Tomcat log management class uses JULI: LOGGING_MANAGER = "-Djava. util. logging. manager = org. apache. juli. ClassLoaderLogManager"

Java stdout and stderr will be redirected to $ CATALINA_BASE/logs/catalina. out. At the same time, the following two types of error messages will be recorded here
Uncaught exceptions printed by java. lang. ThreadGroup. uncaughtException (..
Thread dumps, if you requested them via a system signal


Access log: it is related to general logs but not the same. It is configured in the Context, Host, or Engine of Servlet. xml. Add The following values in The configuration section. For more information, see The Valve Component.
Xml code
<Valve className = "org. apache. catalina. valves. AccessLogValve" directory = "logs"
Prefix = "localhost_access_log." suffix = ". logs" pattern = "common" resolveHosts = "false"/>


Tomcat uses the JULI log system by default (you can refer to the official documentation to change to use log4j), which is the default JDK log java. util. logging must be encapsulated. It supports the same configurations as standard JDK logs. The biggest difference is that different configuration files can be used for different classloader, so that different Web applications in tomcat can use their own log files. That is to say, the default logs in Tomcat have the following two levels:
Global configuration file. that is usually done in the $ {catalina. base}/conf/logging. properties file. the file is specified by the java. util. logging. config. file System property which is set by the startup scripts. if it is not readable or is not configured, the default is to use the $ {java. home}/lib/logging. properties file in the JRE.
Use WEB-INF/classes/logging. properties in Web applications
Logging in the default JRE. properties will output logs to System. err (ConsoleHandler), and the default configuration file conf/logging under Tomcat. properties adds multiple FileHandlers to output logs to different files.

JULI log extension configuration:
Prefix, so that A prefix may be added to handler names, so that multiple handlers of a single class may be instantiated. A prefix is a String which starts with a digit, and ends '. '. for example, 22foobar. is a valid prefix.
Reference System variables, such as $ {catalina. base}/logs/prj. log directly locates the project prj log to the logs directory under tomcat: System property replacement is already Med for property values which contain $ {systemPropertyName }.
As in Java 6.0, loggers can define a list of handlers using the loggerName. handlers property.
By default, loggers will not delegate to their parent if they have associated handlers. This may be changed per logger using the loggerName. useParentHandlers property, which accepts a boolean value.
Root looger: The root logger can define its set of handlers using the. handlers property.


Tomcat JULI log format: use the Engine, Host, and Context to define the log. The Engine is generally Catalina.
Org. apache. catalina. core. ContainerBase. [$ {engine}]. [$ {host}]. [$ {context}]
The default configuration file $ {catalina. base}/conf/logging. properties in Tomcat:
Java code
Handlers = 1catalina.org. apache. juli. FileHandler, 2localhost.org. apache. juli. FileHandler, 3manager.org. apache. juli. FileHandler, java. util. logging. Lelehandler
  
. Handlers = 1catalina.org. apache. juli. FileHandler, java. util. logging. Lelehandler
  
######################################## ####################
# Handler specific properties.
# Describes specific configuration info for Handlers.
######################################## ####################
# Cataline engine log file named catalina. Date. log
1catalina.org. apache. juli. FileHandler. level = FINE
1catalina.org. apache. juli. FileHandler. directory =$ {catalina. base}/logs
1catalina.org. apache. juli. FileHandler. prefix = catalina.
# Logs generated by internal code in Tomcat, with the file name localhost. Date. log
2localhost.org. apache. juli. FileHandler. level = FINE
2localhost.org. apache. juli. FileHandler. directory =$ {catalina. base}/logs
2localhost.org. apache. juli. FileHandler. prefix = localhost.
# Default manager application log in Tomcat, file name manager. Date. log
3manager.org. apache. juli. FileHandler. level = FINE
3manager.org. apache. juli. FileHandler. directory =$ {catalina. base}/logs
3manager.org. apache. juli. FileHandler. prefix = manager.
# Logs output from the console are redirected to catalina. out by default in Linux.
Java. util. logging. Lelehandler. level = FINE
Java. util. logging. Lelehandler. formatter = java. util. logging. SimpleFormatter
  
  
######################################## ####################
# Facility specific properties.
# Provides extra control for each logger.
######################################## ####################
  
Org. apache. catalina. core. ContainerBase. [Catalina]. [localhost]. level = INFO
Org. apache. catalina. core. ContainerBase. [Catalina]. [localhost]. handlers = 2localhost.org. apache. juli. FileHandler
# Wen application/manager logs
Org. apache. catalina. core. ContainerBase. [Catalina]. [localhost]. [/manager]. level = INFO
Org. apache. catalina. core. ContainerBase. [Catalina]. [localhost]. [/manager]. handlers = 3manager.org. apache. juli. FileHandler
# Wen application/host-manager logs
Org. apache. catalina. core. ContainerBase. [Catalina]. [localhost]. [/host-manager]. level = INFO
Org. apache. catalina. core. ContainerBase. [Catalina]. [localhost]. [/host-manager]. handlers = 4host-manager.org.apache.juli.FileHandler
  
# For example, set the com. xyz. foo logger to only log SEVERE
# Messages:
# Org. apache. catalina. startup. ContextConfig. level = FINE
# Org. apache. catalina. startup. HostConfig. level = FINE
# Org. apache. catalina. session. ManagerBase. level = FINE
# Org. apache. catalina. core. AprLifecycleListener. level = FINE

 

Reprinted from: http://bbs.51cto.com/thread-955919-1.html

Tomcat log system details

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.