Search code examples
scalaapache-sparklogbackslf4j

SLF4J Multiple bindings


I've come across the SLF4J: Class path contains multiple SLF4J bindings error in scala. I know there are lot of forums and discussions about this and this warning is not my problem. I can get rid of the warning by excluding one of the conflicting entries in my build.sbt. In my case, the conflicting packages are org.slf4j and ch.qos.logback. So, I can get rid of the warning by entering one of the following in my build.sbt.

libraryDependencies ~= {_.map(_.exclude("ch.qos.logback", "logback-classic"))}

or

libraryDependencies ~= {_.map(_.exclude("org.slf4j", "slf4j-log4j12"))}

My issue is, when I get rid of this warning it messes up the output in the windows command prompt (Yes, this needs to run on windows).

Excluding org.slf4j shows weird characters in the command window. These characters are not displayed in my intelliJ console.

enter image description here

if I exclude ch.qos.logback, the output looks fine but the command prompt doesn't display any log messages below error level.

enter image description here

I think I want to exclude org.slf4j so I can configure my loggers easily using logback.xml. Does anyone have any idea on why there are weird characters on command line in the first case and how to fix it.


Solution

  • Those weird signs are ANSI escape sequences for text coloring and formatting. Probably your logback layout configuration has some coloring enabled. For more details see: https://logback.qos.ch/manual/layouts.html#coloring