Skip to end of metadata
Go to start of metadata


Overview

The overall server logging configuration is represented by the logging subsystem. It consists of four notable parts: handler configurations, logger, the root logger declarations (aka log categories) and logging profiles. Each logger does reference a handler (or set of handlers). Each handler declares the log format and output:


Attributes

The root resource contains two notable attributes add-logging-api-dependencies and use-deployment-logging-config.

add-logging-api-dependencies

The add-logging-api-dependencies controls whether or not the container adds implicit logging API dependencies to your deployments. If set to true, the default, all the implicit logging API dependencies are added. If set to false the dependencies are not added to your deployments.

use-deployment-logging-config

The use-deployment-logging-config controls whether or not your deployment is scanned for per-deployment logging. If set to true, the default, per-deployment logging is enabled. Set to false to disable this feature.

Per-deployment Logging

Per-deployment logging allows you to add a logging configuration file to your deployment and have the logging for that deployment configured according to the configuration file. In an EAR the configuration should be in the META-INF directory. In a WAR or JAR deployment the configuration file can be in either the META-INF or WEB-INF/classes directories.

The following configuration files are allowed:

  • logging.properties
  • jboss-logging.properties
  • log4j.properties
  • log4j.xml
  • jboss-log4j.xml

You can also disable this functionality by changing the use-deployment-logging-config attribute to false.


Logging Profiles

Logging profiles are like additional logging subsystems. Each logging profile constists of three of the four notable parts listed above: handler configurations, logger and the root logger declarations.

You can assign a logging profile to a deployment via the deployments manifest. Add a Logging-Profile entry to the MANIFEST.MF file with a value of the logging profile id. For example a logging profile defined on /subsystem=logging/logging-profile=ejbs the MANIFEST.MF would look like:

A logging profile can be assigned to any number of deployments. Using a logging profile also allows for runtime changes to the configuration. This is an advantage over the per-deployment logging configuration as the redeploy is not required for logging changes to take affect.


Default Log File Locations

Managed Domain

In a managed domain two types of log files do exist: Controller and server logs. The controller components govern the domain as whole. It's their responsibility to start/stop server instances and execute managed operations throughout the domain. Server logs contain the logging information for a particular server instance. They are co-located with the host the server is running on.

For the sake of simplicity we look at the default setup for managed domain. In this case, both the domain controller components and the servers are located on the same host:

Process Log File
Host Controller ./domain/log/host-controller.log
Process Controller ./domain/log/process-controller.log
"Server One" ./domain/servers/server-one/log/server.log
"Server Two" ./domain/servers/server-two/log/server.log
"Server Three" ./domain/servers/server-three/log/server.log

Standalone Server

The default log files for a standalone server can be found in the log subdirectory of the distribution:

Process Log File
Server ./standalone/log/server.log


Filter Expressions

Filter Type Expression Description Parameter(s) Examples
accept accept Accepts all log messages. None accept
deny deny enies all log messages. None deny
not not(filterExpression) Accepts a filter as an argument and inverts the returned value. The expression takes a single filter for it's argument. not(match("JBAS"))
all all(filterExpressions) A filter consisting of several filters in a chain. If any filter find the log message to be unloggable, the message will not be logged and subsequent filters will not be checked. The expression takes a comma delimited list of filters for it's argument. all(match("JBAS"), match("WELD"))
any any(filterExpressions) A filter consisting of several filters in a chain. If any filter fins the log message to be loggable, the message will be logged and the subsequent filters will not be checked. The expression takes a comma delimited list of filters for it's argument. any(match("JBAS"), match("WELD"))
levelChange levelChange(level) A filter which modifies the log record with a new level. The expression takes a single string based level for it's argument. levelChange(WARN)
levels levels(levels) A filter which includes log messages with a level that is listed in the list of levels. The expression takes a comma delimited list of string based levels for it's argument. levels(DEBUG, INFO, WARN, ERROR)
levelRange levelRange([minLevel,maxLevel]) A filter which logs records that are within the level range. The filter expression uses a "[" to indicate a minimum inclusive level and a "]" to indicate a maximum inclusive level. Otherwise use "(" or ")" respectively indicate exclusive. The first argument for the expression is the minimum level allowed, the second argument is the maximum level allowed.
  • minimum level must be greater than DEBUG and the maximum level must be less than to ERROR

    levelRange(DEBUG, ERROR)

  • minimum level must be greater than or equal to DEBUG and the maximum level must be less than ERROR

    levelRange[DEBUG, ERROR)

  • minimum level must be greater than or equal to INFO and the maximum level must be less than or equal to ERROR

    levelRange[INFO, ERROR]
match match("pattern") A regular-expression based filter. The raw unformatted message is used against the pattern. The expression takes a regular expression for it's argument. match("JBAS\d+")
substitute substitute("pattern", "replacement value") A filter which replaces the first match to the pattern with the replacement value. The first argument for the expression is the pattern the second argument is the replacement text. substitute("JBAS", "EAP")
substituteAll substituteAll("pattern", "replacement value") A filter which replaces all matches of the pattern with the replacement value. The first argument for the expression is the pattern the second argument is the replacement text. substituteAll("JBAS", "EAP")

List Log Files and Reading Log Files

Log files can be listed and viewed via management operations. The log files allowed to be viewed are intentionally limited to files that exist in the jboss.server.log.dir and are associated with a known file handler. Known file handler types include file-handler, periodic-rotating-file-handler, periodic-size-rotating-file-handler and size-rotating-file-handler. The operations are valid in both standalone and domain modes.

List Log Files

The logging subsystem has a log-file resource off the subsystem root resource and off each logging-profile resource to list each log file.

CLI command and output

Read Log File

The read-log-file operation is available on each log-file resource. This operation has 4 optional parameters.

Name Description
encoding the encoding the file should be read in
lines the number of lines from the file. A value of -1 indicates all lines should be read.
skip the number of lines to skip before reading.
tail true to read from the end of the file up or false to read top down.
CLI command and output

FAQ

Why is there a logging.properties file?

You may have noticed that there is a logging.properties file in the configuration directory. This is logging configuration is used when the server boots up until the logging subsystem kicks in. If the logging subsystem is not included in your configuration, then this would act as the logging configuration for the entire server.

The logging.properties file is overwritten at boot and with each change to the logging subsystem. Any changes made to the file are not persisted. Any changes made to the XML configuration or via management operations will be persisted to the logging.properties file and used on the next boot.
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Mar 15, 2012

    It would be useful to have a section which explains the role that

    /standalone/configuration/logging.properties

    has and whether it overrides the standalone.xml logging configuration.

    The standalone.bat file includes the system property

    -Dlogging.configuration=....../standalone/configuration/logging.properties

    which suggests it does play a role?

    1. May 30, 2012

      Hello Peter

      The answer is in this same page: Why is there a logging.properties file?

  2. Mar 09, 2013

    Hi

    Can i use logback db appender as a custom -handler..?

    1. Mar 10, 2013

      The forums are really a better place to ask questions like this, https://community.jboss.org/en/jbossas7. That said, no you cannot use logback appenders, but you can use log4j appenders as a custom-handler.

  3. Sep 26, 2013

    Just thought I'd mention that for periodic-rotating-file-handler, append is no longer an attribute, but a tag. On WF8 Alpha4 I get this error: Message: JBAS014788: Unexpected attribute 'append' encountered.

    Replace the attribute with a tag like this: