[logback-dev] Properties in logger name

Eric Charlton ericjcharlton at gmail.com
Tue Nov 1 21:05:20 CET 2011


Thanks Ceki! I see it in 1.0.0 : )

Cheers,
Eric C

On Nov 1, 2011, at 12:51 AM, ceki wrote:

> Hi Eric,
> 
> If you look at LoggerAction from the source repository, you should see that it already does substitution.
> 
> Cheers,
> -- 
> Ceki
> http://twitter.com/#!/ceki
> 
> 
> On 01/11/2011 4:50 AM, Eric Charlton wrote:
>> Hello,
>> 
>> In AppenderAction, there is a line:
>> String appenderName = ec.subst(attributes.getValue(NAME_ATTRIBUTE));
>> 
>> In LoggerAction, this is the equivalent:
>> String loggerName = attributes.getValue(NAME_ATTRIBUTE);
>> 
>> The LoggerAction doesn't substitute from context. My guess is that there is a good reason why properties are not substituted in logger names....? That's my question.
>> 
>> 
>> 
>> Here's where this comes from:
>> 
>> I thought it would be nifty to route some logs via a shared properties file (shared between the app and logback.xml config) like so:
>> 
>> <property resource="logbackProps.properties" />
>> 
>> <logger name="${customLoggerName}>                               <------------this is what doesn't work because LoggerAction doesn't substitute properties
>>     <appender-ref ref="SOME_FILE_APPENDER" />
>> </logger>
>> 
>> 
>> Then put a logger name in the logbackProps.properties file:
>> 
>> customLoggerName=userAuthLogger
>> 
>> Then in code (let's say a user authentication DAO) I could:
>> 
>> private static Logger authenticationlogger = LoggerFactory.getLogger(ClassThatGetsProperties.getPropertyValueFor(ConstantsEnum.customLoggerName));
>> 
>> 
>> Thanks and Cheers!
>> Eric C
> _______________________________________________
> logback-dev mailing list
> logback-dev at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-dev



More information about the logback-dev mailing list