Difference between log4j-to-slf4j and log4j-over-slf4j
我并没有真正了解log4j-to-slf4j.jar和log4j-over-slf4j.jar之间的区别。根据我在互联网上阅读的内容
log4j-to-slf4j.jar:(https://logging.apache.org/log4j/2.x/log4j-to-slf4j/index.html)
"The Log4j 2 to SLF4J Adapter allows applications coded to the Log4j 2
API to be routed to SLF4J. Use of this adapter may cause some loss of
performance as the Log4j 2 Messages must be formatted before they can
be passed to SLF4J. With Log4j 2 as the implementation these would
normally be formatted only when they are accessed by a Filter or
Appender."
log4j-over-slf4j.jar(http://www.slf4j.org/legacy.html)
"It allows log4j
users to migrate existing applications to SLF4J without changing?a
single line of code?but simply by replacing the?log4j.jar?file
with?log4j-over-slf4j.jar, as described below. The log4j-over-slf4j
module contains replacements of most widely used log4j classes, namely
org.apache.log4j.Category, org.apache.log4j.Logger,
org.apache.log4j.Priority, org.apache.log4j.Level,
org.apache.log4j.MDC, and org.apache.log4j.BasicConfigurator. These
replacement classes redirect all work to their corresponding SLF4J
classes."
据我了解,两者都能解决相同的问题。但是到底有什么区别呢?桥接器还是适配器?
非常感谢!
如果我错了,请纠正我-将尝试回答我的问题。
我只是看了mvnrepository.org-版本2.x下没有log4j-to-slf4j.jar,从我上面粘贴的链接中可以看出,这是log4j-2.x的适配器,并且不是1.x。它也是由Apache Foundation提供的。
相反,log4j-over-slf4j.jar记录在slf4j.org上,并且确实将log4j-1.x记录重定向到slf4j-api。
所以我认为我混合了苹果和梨。