Why doesn't slf4j Logger have a logging method?

I wonder why not

logger.log(level, ...) 

      

in slf4j. Is there a specific reason? When switching from log4j to slf4j and using logback, it gives me a headache!

+3


source to share


2 answers


slj4j is just a wrapper around the actual Logger implementation to provide flexibility to change the underlying implementation.

Having said that, instead of .log (,) notation, slf4j uses logger.level () like - logger. debug () logger. info () etc.



and this is also based on the supported LEVEL defined in your basic logger configuration, eg logger.properties.

+2


source


This is just a guess, but I think the type method is log(Level...

not in the interface for some combination of these reasons:



  • Keeping the number of methods in the interface
  • Avoid having to define numerical log levels in the interface
  • With no numeric levels, just enumeration values, the advantage of such a method is not clear.
  • As independent of the baseline log levels as possible without having a log level at all
  • When a dynamic log level is desired by the application, the Token Concept can be an alternative .
0


source







All Articles