1

I have log4j2 in my project and I want to configure logging as follows:

  1. First file: all trace level and one package with debug level.
  2. Second file: All logs of the debug level and higher (except for the package from the first point).

I wrote two appenders and I can't make it so that the logs from the package are written to the desired file

<RollingFile name = "first" filename = "trace.log">
   <ThresholdFilter level = "DEBUG" onMatch ="DENY" onMismatch = "ACCEPT"/>
...
</RollingFile> 

<RollingFile name = "second" filename = "app.log">
   <ThresholdFilter level = "DEBUG" onMatch ="ACCEPT" onMismatch = "DENY"/>
...
</RollingFile> 

<Loggers>
  <Logger name = "com.example" level = "DEBUG" additivity = "false">
    <AppenderRef ref = "first">
  </Logger>
  <RootLogger level = "TRACE">
    <AppenderRef ref = "first">
    <AppenderRef ref = "second">
  </RootLogger>
</Loggers>
Violetta
  • 509
  • 4
  • 12

0 Answers0