Hi everyone, I'm trying to send messages to different files based on a key/value from the current context. To do that I set up 3 appenders all children of root with different ContextMapFilter.
My configuration is attached. Basically one appender will look for "External" entries, the other appender "Internal" and the last one everything else (that's the intention at least). What I'm seeing is ALL log files having the same info. I can confirm the values are being populated in the ThreadContext. Any info or pointers is appreciated. Thanks!
<?xml version="1.0" encoding="UTF-8"?> <Configuration status="DEBUG"> <Appenders> <RollingFile name="APPLICATION" fileName="/logs/app.log" filePattern="${log-path}/application.log.%d{yyyy-MM-dd-HH}"> <PatternLayout pattern="%d{DATE} [%p] (%t) %c: %m%n" /> <Policies> <TimeBasedTriggeringPolicy interval="1" modulate="true" /> </Policies> <ContextMapFilter onMatch="ACCEPT" onMismatch="DENY"> <KeyValuePair key="SERVICE_MODE" value="EXTERNAL"/> </ContextMapFilter> </RollingFile> <RollingFile name="APPLICATION_INT" fileName="${log-path}/app.intern.log" filePattern="/logs/application.internal.log.%d{yyyy-MM-dd-HH}"> <PatternLayout pattern="%d{DATE} [%p] (%t) %c: %m%n" /> <Policies> <TimeBasedTriggeringPolicy interval="1" modulate="true" /> </Policies> <ContextMapFilter onMatch="ACCEPT" onMismatch="DENY"> <KeyValuePair key="SERVICE_MODE" value="INTERNAL"/> </ContextMapFilter> </RollingFile> <RollingFile name="APPLICATION_OTHER" fileName="${log-path}/app.other.log" filePattern="/logs/application.other.log.%d{yyyy-MM-dd-HH}"> <PatternLayout pattern="%d{DATE} [%p] (%t) %c: %m%n" /> <Policies> <TimeBasedTriggeringPolicy interval="1" modulate="true" /> </Policies> <ContextMapFilter onMatch="DENY" onMismatch="NEUTRAL"> <KeyValuePair key="SERVICE_MODE" value="EXTERNAL"/> </ContextMapFilter> <ContextMapFilter onMatch="DENY" onMismatch="NEUTRAL"> <KeyValuePair key="SERVICE_MODE" value="INTERNAL"/> </ContextMapFilter> </RollingFile> </Appenders> <Loggers> <Root level="DEBUG"> <AppenderRef ref="APPLICATION"/> <AppenderRef ref="APPLICATION_INT"/> <AppenderRef ref="APPLICATION_OTHER"/> </Root> </Loggers> </Configuration>
--------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org