Introduction

The logging framework used in the DuraCloud application is SLF4J with the LogBack implementation statically bound at runtime.
See the LogBack website for a detailed description of the configuration options.

The application also contains bridges for both Log4J and Commons-Logging which translates any underlying, dependency libraries which are configured to write to these frameworks into the SLF4J API. The effect is that all logging is channeled through the SLF4J configuration.

General Usage

  • By default, if no configuration file is found by LogBack, the logging level is set to "DEBUG" and the appender is set to "STDOUT"
  • When starting any DuraCloud application, a LogBack configuration file may be specified by using the following system variable

    java -Dlogback.configurationFile={path-to-logging-configuration-file} -jar any-application
    
  • Additionally, LogBack will use the file named "logback.xml" found at the top of the classpath for configuration
  • An example logback.xml file can be found on here.

    1<?xml version="1.0" encoding="UTF-8"?>
    2
    3<configuration >
    4  <!--<configuration debug="true" scan="true">-->
    5  <jmxConfigurator/>
    6  <property name="LOG_FILENAME" value="/home/duraspace/logs/duracloud-osgi.log" />
    7
    8  <appender name="DURACLOUD" class="ch.qos.logback.core.rolling.RollingFileAppender">
    9    <File>${LOG_FILENAME}</File>
    10    <encoder>
    11      <pattern>%-14p %d{yyyy/MM/dd HH:mm:ss} [%t] (%F:%L\\) [%M(\\)] - %m%n</pattern>
    12    </encoder>
    13    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
    14      <maxIndex>5</maxIndex>
    15      <FileNamePattern>${LOG_FILENAME}.%i</FileNamePattern>
    16    </rollingPolicy>
    17    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
    18      <MaxFileSize>20MB</MaxFileSize>
    19    </triggeringPolicy>
    20  </appender>
    21  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    22    <encoder>
    23      <pattern>%-14p %d{yyyy/MM/dd HH:mm:ss} [%t] (%F:%L\\) [%M(\\)] - %m%n</pattern>
    24    </encoder>
    25  </appender>
    26  <logger name="org.duracloud" level="DEBUG" additivity="false">
    27    <appender-ref ref="DURACLOUD"/>
    28  </logger>
    29   <root level="WARN">
    30    <appender-ref ref="STDOUT"/>
    31  </root>
    32</configuration>
    
  • Notes on the above logback.xml file
    • on line 4, the attribute "debug" applies to displaying configuration information when LogBack starts up if set to "true"
    • on line 4, the attribute "scan" configures LogBack to re-read the given logback.xml every 60 seconds (by default) for updates
    • on line 26, the attribute "additivity" configures the given logger to inherit the configuration of the parent logger, in this case, the root logger
    • on line 26, if the "additivity" attribute were set to "true", all "DURACLOUD" log output would also log to "STDOUT"
  • No labels