Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-403

SiftingAppender does not substitute variable value inside sift

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 1.0.12
    • 1.0.0
    • logback-classic
    • None
    • Ubuntu 11.04, Eclipse 3.7

    Description

      Faced a probable bug (at least, did not find any mention about such issue at manual/google/other bugs in category).

      Brief logging configuration description:
      I have a property defined in my logback configuration.
      There is a property with log file location defined:
      <property name="LOG_HOME" value="/tmp/aicore" />
      Also, I have ConsoleAppender and two RollingFileAppender appenders, attached to root logger. RollingFileAppender configuration contains LOG_HOME variable in path and substitution is done without any issues, log file is created and updated.
      But when I add SiftingAppender (log files are created on per-threadId basis), that contains FileAppender in it's sift section, variable value is not substituted.
      Here is the logback log fragment, generated using OnConsoleStatusListener:

      22:11:27,396 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
      22:11:27,396 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE-server]
      22:11:27,398 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
      22:11:27,400 |-INFO in ch.qos.logback.core.FileAppender[FILE-server] - File property is set to [LOG_HOME_IS_UNDEFINED/thread-server.log]

      Note the "LOG_HOME_IS_UNDEFINED/thread-server.log" value. As a result, no any sift log file is created in expected location. When I substitute ${LOG_HOME} value manually, everything works well.

      Below is my SiftingAppender config:

      <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
      <discriminator class="ch.qos.logback.classic.sift.MDCBasedDiscriminator">
      <key>threadId</key>
      <defaultValue>unclassified</defaultValue>
      </discriminator>
      <sift>
      <appender name="FILE-${threadId}" class="ch.qos.logback.core.FileAppender">
      <file>${LOG_HOME}/thread-${threadId}.log</file>
      <append>false</append>
      <encoder>
      <pattern>%d [%thread] %level %mdc %logger

      {35}

      - %msg%n</pattern>
      </encoder>
      </appender>
      </sift>
      </appender>

      Sorry if bug report is not formed perfectly, I have not much expertise yet

      Attachments

        Activity

          People

            logback-dev Logback dev list
            dmitriusan Dmytro Lisnichenko
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: