[logback-user] Can we have more then one varable in file name

ceki ceki at qos.ch
Thu May 30 12:00:59 CEST 2013

Hi David,

I am guessing that it should be fairly easy to allow multiple
key/values to be exported by the discriminator, especially if divide
the problem into two parts: 1) tracking appenders by single
discriminating value and 2) configuring appenders by exporting
multiple keys/values.

I don't see the use case for tracking appenders by multiple
discriminating values. So if only one value is allowed for tracking,
we can keep the existing tracking "as is" and focus on the variable
exporting part for appender configuration.

Pursuing this hypothesis, we could add a new method to the
Discriminator interface to export a map of keys and values, instead of
the a single key/value pair. For example here is the modified
Discriminator interface:

public interface Discriminator<E> extends LifeCycle {
   String getDiscriminatingValue(E e);

   // the getKey() method is probably no longer useful
   String getKey();

   // new method Map<String, String> getOneTimePropertyMap(); }

Such a change would be backwards incompatible but it seems that
supporting multiple keys would justify breaking compatibility
especially since only existing Discriminator implementations would be

Changes to AppenderFactory/SiftingJoranConfigurator should be fairly


On 30.05.2013 10:35, David Roussel wrote:
> Praveen,
> I think sifting appender can only use one key from the MDC in the file name.
> It would be nice to use more, but that would require changes in logback. In fact I've wanted to do this before. But made a work around with two sifting appender and a filter.
> David
> On 30 May 2013, at 10:28, praveen patil <iampraveenpatil at gmail.com> wrote:
>> Hi everyone
>> I am setting two variable in MDC and then in my appender in file tag i gave two variable ${configId} and ${threadName}. but when i run it i get only threadName value and for ${configId} it shows configId is UNDEFIND. but when the mdc context i found it is in the context, then why it giving error.
>> <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
>>          <discriminator class="com.hotwaxmedia.logger.ThreadNameBasedDiscriminator"/>
>>          <sift>
>>              <appender class="ch.qos.logback.core.FileAppender">
>>                  <file>runtime/logs/DataManagerLog/${configId}-${threadName}.html</file>
>>                  <layout class="ch.qos.logback.classic.PatternLayout">
>>                      <pattern><div class="%p">%d \(${threadName} -%X{configId}\) [%logger{0} : %-5level] %msg%n%rEx</div></pattern>
>>                  </layout>
>>              </appender>
>>          </sift>
>>      </appender>
>> please help.
>> Praveen

65% of statistics are made up on the spot

More information about the Logback-user mailing list