[logback-dev] Properties in logger name

Eric Charlton ericjcharlton at gmail.com
Tue Nov 1 04:50:51 CET 2011


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


More information about the logback-dev mailing list