WildFly Logging Subsystem Configuration

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Relevance

  • EAP 6.4

Overview

<subsystem xmlns="urn:jboss:domain:logging:1.5">

    <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>
    <logger category="org.apache.tomcat.util.modeler">
        <level name="WARN"/>
    </logger>
    <logger category="org.jboss.as.config">
        <level name="DEBUG"/>
    </logger>
    <logger category="sun.rmi">
        <level name="WARN"/>
    </logger>
    <logger category="jacorb">
        <level name="WARN"/>
    </logger>
    <logger category="jacorb.config">
        <level name="ERROR"/>
     </logger>
     <root-logger>
         <level name="INFO"/>
         <handlers>
            <handler name="FILE"/>
         </handlers>
      </root-logger>
      <formatter name="PATTERN">
         <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
      </formatter>
</subsystem>

<root-logger>

Note that the level has to be explicitly specified in <root-logger> to limit logging, in this case INFO. If <level name="INFO"/> is missing, the default is "ALL", so TRACE logging will be generated in the handlers that are not explicitly limited, such as the file handler.

WildFly Logging Subsystem Configuration

WildFly Logging Subsystem CLI Configuration

Periodic Rotating File Handler Configuration

https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuration_guide/logging_with_jboss_eap#configure_periodic_size_log_handler

The rotation period is inferred based on the "suffix" value. The "suffix" is a string that can be parsed with java.text.SimpleDateFormat. The rotation period is the shortest identified amongst the following:

  • yearly if the suffix string contains "y".
  • monthly if the suffix string contains "M".
  • weekly if the suffix contains "w" or "W".
  • daily if the suffix contains "D", "d" "F" or "E"
  • half day if the suffix contains "a", "H", "k" or "K"
  • hourly if the suffix contains "h"
  • every minute if the suffix contains "m"

Seconds and milliseconds are not supported.

<periodic-rotating-file-handler name="TEST" autoflush="true">
    <level name="ALL"/>
    <file relative-to="jboss.server.log.dir" path="test.log"/>
    <suffix value=".yyyy-MM-dd"/>
    <append value="true"/>
</periodic-rotating-file-handler>

<periodic-rotating-file-handler> rotates the logs on a time interval basis, but only if there is activity in the logs. If configured to rotate on a daily basis ("d" present in the suffix pattern), but the instance is left to idle, the logs won't rotate simply because the logs are not written.

TO CLARIFY:

If configured with both rotate-siz and max-backup-index, <periodic-rotating-file-handler> may end up with daily gaps in the logs. This is why this may happen: ....

<periodic-size-rotating-file-handler name="FILE" ...>
    ...
    <rotate-size value="100m"/>
    <max-backup-index value="7"/>
    <suffix value=".yyyy-MM-dd"/>
    ...
</periodic-size-rotating-file-handler>

Size Rotating File Handler Configuration

https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuration_guide/logging_with_jboss_eap#configure_size_log_handler
https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuration_guide/reference_material#size_log_handler_attributes

A handler that writes log data into files that can grow up to a configured maximum size, after which a new file is started. The maximum size is configured with

rotate-size

The maximum size that the log file will grow to before it is rotated. A single character appended to the number indicates the size units: 'b' for bytes, 'k' for kilobytes, 'm 'for megabytes, 'g' for gigabytes.

max-backup-index

The maximum number of individual log files that are kept. When this number is reached, the oldest log is overwritten and the old data is discarded. The default is 1.

If the suffix attribute is used, the suffix of rotated log files is included in the rotation algorithm. When the log file is rotated, the oldest file whose name starts with name+suffix is deleted, the remaining rotated log files have their numeric suffix incremented and the newly rotated log file is given the numeric suffix 1.

Does it mean that logs are also time rotated? If that is the case, why do we have a <periodic-rotating-file-handler>?

suffix

This string is included in the suffix appended to rotated logs. The format of the suffix is a dot (.) followed by a date string which is able to be parsed by the SimpleDateFormat class.

Example

Example of a rolling size-limited window of 8 GB:

<subsystem xmlns="urn:jboss:domain:logging:1.5">
    <size-rotating-file-handler name="FILE" autoflush="true" rotate-on-boot="true">
        ...
        <rotate-size value="400m"/>
        <max-backup-index value="20"/>
        <append value="false"/>
    </size-rotating-file-handler>
    ...
</subsystem>