slf4j log4j logback

We are the first to write a log with log4j, and later of innovation, but also staged a logback, and in order to unify the dead, came a slf4j, we now have a log output in the code, it is recommended to use slf4j, so at run time, you can the decision in the end is to use log4j or logback, according to their different profiles can handle that.

The basic principle is slf4j -> adator -> log, see below:

 

But for older projects before, or with log4j output, is it possible to go with logback output without changes to the code?

The answer is yes, remove the log4j package and run-time environment configuration file, adding environment logback packages and configuration files, the key point here, as well as adding log4j-over-slf4j in the runtime environment package and slf4j-api package.

Principle or adaptor, application -> log4j-over-slf4j (originally log4j) -> slf4j-api -> logback, as follows:

Details, see: https: //www.slf4j.org/manual.html

https://www.slf4j.org/legacy.html

https://www.tuicool.com/articles/INveIf

Guess you like

Origin www.cnblogs.com/029zz010buct/p/10981277.html