I don't remember if there's a simpler way to do it, but the advanced way of
doing this would be using a RoutingAppender which delegates to those two
different appender refs you have.

You can also take a look at additivity which is related to what you're
asking about.

On 7 December 2017 at 06:10, Asma Zinneera Jabir <azinne...@gmail.com>

> I want package com.abc.xyz to log only ERRORs to the console and INFO and
> above to a file. How do I give the configuration in log4j2.xml for this?
> Tried doing the below but didn't work.
> <Loggers>
> <Root level="info">
> <AppenderRef ref="CONSOLE"/>
> <AppenderRef ref="LOGFILE"/>
> </Root>
> <Logger name="com.abc.xyz">
>      <AppenderRef ref="LOGFILE" level="info"/>
>      <AppenderRef ref="CONSOLE" level="error" />
>     </Logger>
> </Loggers>

Matt Sicker <boa...@gmail.com>

Reply via email to