Ed Graham
Ed Graham

Reputation: 4685

How to send logs with different levels to different appenders using log4j2.properties file?

I'm using log4j2 and am trying to have different log messages go to different appenders within the same logger. This case is described exactly in the log4j2 FAQ - but I need to use the log4j2.properties configuration file instead of the XML configuration given in the example.

Another example with an XML configuration file is given here - essentially, I don't know how to specify the lines

<AppenderRef ref = "Console" level ="info"/>
<AppenderRef ref = "hibernateFile" level = "debug"/>

in log4j2.properties syntax.

Upvotes: 2

Views: 672

Answers (1)

Vikas Sachdeva
Vikas Sachdeva

Reputation: 5813

You can try below syntax -

rootLogger.level = trace
rootLogger.appenderRef.file.ref = file
rootLogger.appenderRef.file.level = DEBUG
rootLogger.appenderRef.stdout.ref = STDOUT
rootLogger.appenderRef.stdout.level = INFO

Upvotes: 1

Related Questions