Chapter 4. Logging for Developers
4.1. Introduction
4.1.1. About Logging
Logging is the practice of recording a series of messages from an application that provide a record (or log) of the application's activities.
Log messages provide important information for developers when debugging an application and for system administrators maintaining applications in production.
Most modern logging frameworks in Java also include other details such as the exact time and the origin of the message.
4.1.2. Application Logging Frameworks Supported By JBoss LogManager
JBoss LogManager supports the following logging frameworks:
- JBoss Logging - included with JBoss Enterprise Application Platform 6
- Apache Commons Logging - http://commons.apache.org/logging/
- Simple Logging Facade for Java (SLF4J) - http://www.slf4j.org/
- Apache log4j - http://logging.apache.org/log4j/1.2/
- Java SE Logging (java.util.logging) - http://download.oracle.com/javase/6/docs/api/java/util/logging/package-summary.html
4.1.3. About Log Levels
Log levels are an ordered set of enumerated values that indicate the nature and severity of a log message. The level of a given log message is specified by the developer using the appropriate methods of their chosen logging framework to send the message.
JBoss Enterprise Application Platform 6 supports all the log levels used by the supported application logging frameworks. The most commonly used six log levels are (in order of lowest to highest):
TRACE
, DEBUG
, INFO
, WARN
, ERROR
and FATAL
.
Log levels are used by log categories and handlers to limit the messages they are responsible for. Each log level has an assigned numeric value which indicates its order relative to other log levels. Log categories and handlers are assigned a log level and they only process log messages of that level or higher. For example a log handler with the level of
WARN
will only record messages of the levels WARN
, ERROR
and FATAL
.
4.1.4. Supported Log Levels
Table 4.1. Supported Log Levels
Log Level | Value | Description |
---|---|---|
FINEST | 300 |
-
|
FINER | 400 |
-
|
TRACE | 400 |
Use for messages that provide detailed information about the running state of an application. Log messages of
TRACE are usually only captured when debugging an application.
|
DEBUG | 500 |
Use for messages that indicate the progress individual requests or activities of an application. Log messages of
DEBUG are usually only captured when debugging an application.
|
FINE | 500 |
-
|
CONFIG | 700 |
-
|
INFO | 800 |
Use for messages that indicate the overall progress of the application. Often used for application startup, shutdown and other major lifecycle events.
|
WARN | 900 |
Use to indicate a situation that is not in error but is not considered ideal. May indicate circumstances that may lead to errors in the future.
|
WARNING | 900 |
-
|
ERROR | 1000 |
Use to indicate an error that has occurred that could prevent the current activity or request from completing but will not prevent the application from running.
|
FATAL | 1100 |
Use to indicate events that could cause critical service failure and application shutdown and possibly cause JBoss Enterprise Application Platform 6 to shutdown.
|
4.1.5. Default Log File Locations
These are the log files that get created for the default logging configurations. The default configuration writes the server log files using periodic log handlers
Table 4.2. Default Log Files for a standalone server
Log File | Description |
---|---|
EAP_HOME/standalone/log/boot.log |
The server boot log. Contains log messages related to the startup of the server.
|
EAP_HOME/standalone/log/server.log |
The Server Log. Contains all log messages once the server has launched.
|
Table 4.3. Default Log Files for a managed domain
Log File | Description |
---|---|
EAP_HOME/domain/log/host-controller/boot.log |
Host Controller boot log.Contains log messages related to the startup of the host controller.
|
EAP_HOME/domain/log/process-controller/boot.log |
Process controller boot log. Contains log messages related to the startup of the process controller.
|
EAP_HOME/domain/servers/SERVERNAME/log/boot.log |
Server Boot log for the named server. Contains log messages related to the startup of the specified server.
|
EAP_HOME/domain/servers/SERVERNAME/log/server.log |
The server log for the named server. Contains all log messages for that server once it has launched.
|