qos-ch / slf4j

Simple Logging Facade for Java
http://www.slf4j.org
MIT License
2.34k stars 990 forks source link

Add support for log level independent logging #374

Open tglaeser opened 11 months ago

tglaeser commented 11 months ago

Besides ordinary/journal logging there are other logging needs like audit, trace, and metrics logging. Those other types of logging have all in common that the log message shall be published independently of a logging level.

Log4J2 supports such use cases by invoking org.apache.logging.log4j.spi.ExtendedLogger#logIfEnabled with level set to org.apache.logging.log4j.Level#OFF.

How would SLF4J support such use cases? It would be nice to have a method like org.slf4j.Logger#atOff#log(org.slf4j.Marker, java.lang.String) or org.slf4j.Logger#log(org.slf4j.Marker, java.lang.String) with a corresponding binding to Log4J2 that always publishes a log message independently of the log level.

Without such, the above mentioned use cases cannot elegantly implemented using this facade.