[logback-dev] Properties in logger name

ceki ceki at qos.ch
Tue Nov 1 08:51:02 CET 2011


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


More information about the logback-dev mailing list