WildFly Logging Subsystem Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 72: Line 72:


==Console==
==Console==
Console log handlers write log messages to either the host operating system's standard out (stdout) or standard error (stderr) stream. Those messages are not saved by default.


==File==
==File==

Revision as of 00:24, 20 October 2016

External

Internal

Overview

The logging subsystem is based on JBoss LogManager and supports several third-party application logging frameworks, in addition to JBoss Logging: Apache Commons Logging, Simple Logging Facade for Java (SLF4J), Apache log4j and Java SE logging (java.util.logging).

Default Configuration

<subsystem xmlns="urn:jboss:domain:logging:1.5">
    <console-handler name="CONSOLE">
        <level name="INFO"/>
        <formatter>
            <named-formatter name="COLOR-PATTERN"/>
        </formatter>
    </console-handler>
    <periodic-rotating-file-handler name="FILE" autoflush="true">
        <formatter>
            <named-formatter name="PATTERN"/>
        </formatter>
        <file relative-to="jboss.server.log.dir" path="server.log"/>
        suffix value=".yyyy-MM-dd"/>
        <append value="true"/>
    </periodic-rotating-file-handler>
    <logger category="com.arjuna">
        <level name="WARN"/>
    </logger>
    ...
    <root-logger>
        <level name="INFO"/>
        <handlers>
            <handler name="CONSOLE"/>
            <handler name="FILE"/>
        </handlers>
    </root-logger>
    <formatter name="PATTERN">
         <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
    </formatter>
    <formatter name="COLOR-PATTERN">
        <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
    </formatter>
</subsystem>

Logger

Root Logger

The root logger captures all log messages (of a specified level) that are not captured by a log category.

Category

A log category defines what messages to capture.The log messages to capture are defined by their Java package of origin.

A log category is assigned a log level and it only process log messages of that level or higher.

More about categories is available here: https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Administration_and_Configuration_Guide/chap-The_Logging_Subsystem.html#About_Log_Categories

Handler

A log handler defines how to deal with generated log messages.

A handler is assigned a log level and it only process log messages of that level or higher.

The available log handlers are the following:

Console

Console log handlers write log messages to either the host operating system's standard out (stdout) or standard error (stderr) stream. Those messages are not saved by default.

File

Periodic

Size

Async

syslog

Periodic Size

Custom

Level

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 method specific to chosen logging framework.

Log levels are used by log categories and handlers to limit the messages they are responsible for. Log categories and handlers are assigned a log level and they only process log messages of that level or higher.

JBoss supports all the log levels used by the supported application logging frameworks.

FINEST

Value: 300

FINER

Value: 400

TRACE

Value: 400. Should be used for messages that provide detailed information about the running state of an application, and they should only be captured when debugging the application.

DEBUG

Value: 500. DEBUG messages should only be captured when debugging an application.

FINE

Value: 500.

CONFIG

Value: 700

INFO

Value: 800. Use for messages that indicate the overall progress of the application. Often used for application startup, shutdown and other major lifecycle events.

WARN

Value: 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

Value: 900.

ERROR

Value 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.

SEVERE

Value 1000.

FATAL

Value 1100. Use to indicate events that could cause critical service failure and application shutdown and possibly application server shutdown.

Filter

Filter expressions can be used to filter log messages based on various criteria. The filter is always applied on the raw log message. Filters can be added for a logger or a handler. If a filter is added to a logger and a handler, the logger filter takes precedence.

A filter expression is specified by the filter-spec element.

Log Formatter

Logging Profile

A logging profile is a named set of logging configurations, which can be created and assigned to applications.

Boot Logging

Details about the Java environment and component service startup are logged during the JBoss instance startup in the server.log file. The configuration of boot logging is specified in the configuration file logging.properties. The location of the configuration file defense on the mode in which JBoss runs ($JBOSS_HOME/standalone/configuration/logging.properties, $JBOSS_HOME/domain/configuration/logging.properties for the domain controller and $JBOSS_HOME/domain/servers/<server-name>/data/logging.properties.

The start of the boot sequence is marked by "JBAS015899".

logging.properties is active until the logging subsystem is started and takes over.

Garbage Collection Logging

GC logging is enabled by default for standalone mode. It generates output to $JBOSS_HOME/standalone/log/gc.log.<digit>. The system uses log rotation with the number of log files limited to 5, and the size of each file limited to 3 MB.

Logging Dependencies Exposed to Deployments

Whether logging dependencies are exposed or not to deployments is controlled by the add-logging-api-dependencies attribute of the logging subsystem. By default the attribute is set to true.