FreeKB - Tomcat Getting Started with Logs
Tomcat - Getting Started with Logs

The ${catalina.base}/conf/logging.properties file controls how Tomcat handles logging. Following is an excerpt of a logging.properties file. This file specifies the log level, the directory where log files will reside, and the log file prefix, such as catalina, localhost, and manager.

In this example, the "Handler specific properties" section of logging.properties is set to log events at log level FINE or higher. This doesn't mean that events at log level FINE are being captured. This simply means that if there are events at log level FINE or higher, they will be appended to the appropriate log file. 

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.

2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.

3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.

 

In this example, the "Facility specific properties" section of logging.properties is set to log certain events at log level INFO or higher. 

############################################################
# 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

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler

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

 


Log Levels

By default, the log level is set to FINE. The log levels that can be used are:

  • SEVERE - Serious failures
  • WARNING - Potential problems
  • INFO - Informational messages
  • CONFIG - Static configuration messages
  • FINE - Trace messages
  • FINER - Detailed trace messages
  • FINEST - Highly detailed trace messages

 


access logs

The $CATALINA_HOME/conf/server.xml file controls how events are written to the access log. By default, the server.xml file should have something similar to the following.

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="localhost_access_log" suffix=".txt"
       pattern="%h %l %u %t &quot;%r&quot; %s %b" />

 

The above will create log files in the $CATALINA_HOME/logs/ directory. The log files will be named localhost_access_log.date.txt.

Let's use a scenario where the Tomcat server has IP address 10.0.0.1 and a client with IP address 10.0.0.2 navigates to http://tomcat_hostname:8080 to get the Tomcat web interface. This will write the following events in the access log. The access log contains the IP address of the remote machine, the date and time a request was requested, the resource that was requested, and the status code.

10.0.0.2 - - [07/Jul/2017:10:07:47 -0500] "GET / HTTP/1.1" 200 11256
10.0.0.2 - - [07/Jul/2017:10:07:47 -0500] "GET /tomcat.css HTTP/1.1" 200 5581
10.0.0.2 - - [07/Jul/2017:10:07:47 -0500] "GET /tomcat.png HTTP/1.1" 304 -
10.0.0.2 - - [07/Jul/2017:10:07:47 -0500] "GET /bg-nav.png HTTP/1.1" 304 -
10.0.0.2 - - [07/Jul/2017:10:07:47 -0500] "GET /asf-logo-wide.svg HTTP/1.1" 304 -
10.0.0.2 - - [07/Jul/2017:10:07:47 -0500] "GET /bg-upper.png HTTP/1.1" 304 -
10.0.0.2 - - [07/Jul/2017:10:07:47 -0500] "GET /bg-middle.png HTTP/1.1" 304 -
10.0.0.2 - - [07/Jul/2017:10:07:47 -0500] "GET /bg-button.png HTTP/1.1" 304 -
10.0.0.2 - - [07/Jul/2017:10:07:47 -0500] "GET /favicon.ico HTTP/1.1" 200 21630

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 0a122 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |