The Logger Component


[Introduction] [Common Attributes] [Standard Implementation Attributes]

Introduction

A Logger component represents a mechanism by which event, error, and debugging information from a Catalina component, or group of such components, can be directed to a common destination. Each Logger is associated with a Container, by being nested inside the corresponding <Engine>, <Host>, or <Context> element for that Container.

If you attach a Logger to an outer Container (such as an Engine, that logger will be used for all nested Containers (Host and Context components), unless you specifically nest a different logger inside the nested Container.


Common Attributes

All implementations of the Logger component support the following attributes:

Attribute Description
className Java class name of the implementation to use. This class must implement the org.apache.catalina.Logger interface. Because there is no single standard implementation, this attribute is required. See Standard Implementation Attributes for the names of the supported classes.
verbosity The verbosity level for this logger. Messages with a higher verbosity than the specified level will be silently ignored. Available levels are 0 (fatal messages only), 1 (errors), 2 (warnings), 3 (information), and 4 (debug). If not specified, the default value is 1 (error). Note that messages logged with no verbosity parameter are logged unconditionally.

Standard Implementation Attributes

Unlike most other Catalina components, there is not a single standard implementation of the Logger component available. Instead, a variety of standard implementations are available for your use. To select one, use the specified value for the className attribute, and configure the remaining attributes as described below.

File Logger (org.apache.catalina.logger.FileLogger)

The File Logger records all logged messages (other than those ignored based on verbosity level) to disk file(s) in a specified directory. The actual filenames of the log files are created from a configured prefix, the current date in YYYY-MM-DD format, and a configured suffix. At midnight each night, the next logged message causes a switch to a new log file (based on the new date), without having to shut down Catalina in order to switch logs.

The File Logger supports the following additional attributes:

Attribute Description
directory Relative or absolute pathname of the directory into which log files will be created. If a relative path is specified, it is interpreted as relative to $CATALINA_HOME. If no directory is specified, the default value is "logs" (relative to the Catalina home directory).
prefix The prefix added to the front of each log file name. If not specified, the default value is "catalina.". To specify no prefix, use a zero-length string.
suffix The suffix added to the end of each log file name. If not specified, the default value is ".log". To specify no suffix, use a zero-length string.
timestamp Should log messages be date/time stamped? Set this value to true or false. If not specified, log messages will not be date/time stamped.

Standard Error Logger (org.apache.catalina.logger.SystemErrLogger)

The Standard Error Logger records all logged messages (other than those ignored based on verbosity level) to whatever stream the standard error output of Catalina is pointed at. The default Catalina startup script points this at file logs/catalina.out relative to $CATALINA_HOME. This Logger accepts no additional attributes.

Standard Output Logger (org.apache.catalina.logger.SystemOutLogger)

The Standard Output Logger records all logged messages (other than those ignored based on verbosity level) to whatever stream the standard output of Catalina is pointed at. The default Catalina startup script points this at file logs/catalina.out relative to $CATALINA_HOME. This Logger accepts no additional attributes.