[logback-user] Is it possible to acces MDC values as properties?

Ralph Goers rgoers at apache.org
Wed Feb 22 15:54:27 CET 2012


I'm not understanding what you are doing. There are ways to do what you want without resorting to what you have below. For example, the sifting appender will route data to different log files.

When Logback reconfigures it removes all the filters and appenders that have been configured and for a time the loggers have no configuration at all. I then uses your new configuration to add back the filters and appenders and have the loggers reference them. Thus, you will lose everything you configured programmatically when you update logback.xml.   

Ralph

On Feb 22, 2012, at 5:17 AM, Stefan Eder wrote:

> Hi,
> 
> applies to Logback classic 1.0.0.
> 
> Is it possible to acces MDC values as properties like this:
> <file>${catalina.base}/logs/exchanges/${breadcrumbId}-gsem.log</file>
> <encoder>
> <pattern>...</pattern>
> </encoder>
> where 'breadcrumbId' is mapped in the MDC.
> 
> The above example produces a file named breadcrumbId_IS_UNDEFINED-gsem.log.
> The snippet is used in a sifting appender, but 'breadcrumbId' is not the descriminator.
> 
> Do I have to use another notation or do I have to implement ch.qos.logback.core.spi.PropertyDefiner?
> 
> Thanks,
> Stefan
> 
> 
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user



More information about the Logback-user mailing list