WildFly Logging Subsystem Concepts: Difference between revisions

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


A log category defines what messages to capture.
A log category defines what messages to capture.
A log category is assigned a [[#Level|log level]] and it only process log messages of that level or higher.


=Handler=
=Handler=

Revision as of 00:07, 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

Category

A log category defines what messages to capture.

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

Handler

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

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.

JBoss supports all the log levels used by the supported application logging frameworks. The most commonly used are:

  • TRACE
  • DEBUG
  • INFO
  • WARN
  • ERROR
  • FATAL.

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.

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.

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.