[logback-dev] [JIRA] Commented: (LBCLASSIC-312) SiftingAppender does not substitute variable value inside sift

Dieter Mueller (JIRA) noreply-jira at qos.ch
Thu Mar 8 09:01:27 CET 2012

    [ http://jira.qos.ch/browse/LBCLASSIC-312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12374#action_12374 ] 

Dieter Mueller commented on LBCLASSIC-312:

Perhaps not a bug!

Today I accidentally stumbled across the release notes of logback 1.0.0 (when reading the release notes of 1.0.1.):

"Breaking change: properties are no longer automatically inserted into the context"
and a link to http://logback.qos.ch/manual/configuration.html#variableSubstitution.

When I changed the property-definition to scope="context", then the property substitution 
worked within the SiftingAppender.

So this showstopper is for us removed, we may move to logback 1.0.1.

For me it is not 100% clear, what the difference between scope="local" and scope="context" is:
Within the file name of the "normal" appenders it works with "local", but only within the SiftingAppender "context" is needed.

Hope this helped,

Dieter Mueller

> SiftingAppender does not substitute variable value inside sift
> --------------------------------------------------------------
>                 Key: LBCLASSIC-312
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-312
>             Project: logback-classic
>          Issue Type: Bug
>          Components: appender
>    Affects Versions: 1.0.0
>         Environment: Ubuntu 11.04,  Eclipse 3.7
>            Reporter: Dmitrius Listo
>            Assignee: Logback dev list
>         Attachments: log.txt, logback.xml
> 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 :)

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the logback-dev mailing list