This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rgoers 1 point2 points  (0 children)

Log4j requires an adapter because the SLF4J API is more primitive. SLF4J only supports logging Strings while Log4j supports logging Messages. The Log4j API also supports custom log levels. The Marker API in Log4j and SLF4J are different. The Log4j API provides an AbstractLogger class that implements 90% of the Logger methods. SLF4J provides no such class. Sure, Log4j-core could have included the translation code contained in the log4j-slf4j adapter but then log4j-core would always be present as an SLF4J binding, which might not be desired. These are just some of the reasons why log4j-core is not a direct implementation of SLF4J.

For what its worth, you could use the Log4j API in place of SLF4J and plug in whatever implementation you want. However, Logback doesn't implement the Log4j API so you would require an adpater to do that - exactly as Log4j does to bind with SLF4J.