logback log filter

 

1. Level filter

  LevelFilter:  Level filter, to filter the logs of a certain level.

The three sub-labels are

  • level: log level.
  • onMatch: operation on logs that meet the filtering level. Optional values ​​(DENY, NEUTRAL, ACCEPT)
  • onMismatch: onMismatch: operation on logs that do not meet the filtering level. Optional values ​​(DENY, NEUTRAL, ACCEPT)

Write the following record logs in the code respectively.

log.trace(0)

log.debug(1)

log.info(2)

log.warn(3)

log.error(4)

According to the above configuration, we filter the info level.

1. OnMatch is configured with Accept, which means to accept the action of the log that meets the info level, and then print.

2. OnMismatch does (DENY) reject actions for logs that do not conform to the info level, it will not accept log records of other levels except info.

In summary: get the print result as     

2019-06-30 17:3:19.231 [http-nio-8888-exec-1] INFO  1

2. Threshold filter

ThresholdFilter:  Threshold value filter to filter out logs below the specified threshold value.

As configured above, using the threshold value filter, when we configure DEBUG, it will filter out the log records below the level of DEBUG, which is based on

TRACE < DEBUG < INFO < WARN < ERROR

In addition to the trace level log is not printed, other logs will be recorded

 

Published 115 original articles · Like 58 · Visits 160,000+

Guess you like

Origin blog.csdn.net/luChenH/article/details/103868065