Maybe there are two issues:
- version mismatching of your dependencies
- an issue when you deploy your application
For reproducing your error I've created this mini program:
package de.so;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DemoSlf4j
{
private static Logger logger = LoggerFactory.getLogger(DemoSlf4j.class);
public static void main(String[] args)
{
logger.error("Start ...");
}
}
with only these dependencies (same as you used) in pom.xml:
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
</dependencies>
I've got these messages:
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found
binding in
[jar:file:/D:/Maven-Repo/org/slf4j/slf4j-log4j12/1.5.6/slf4j-log4j12-1.5.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/D:/Maven-Repo/org/slf4j/slf4j-simple/1.7.21/slf4j-simple-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
explanation. SLF4J: Actual binding is of type
[org.slf4j.impl.Log4jLoggerFactory] SLF4J: The requested version 1.5.6
by your slf4j binding is not compatible with [1.6, 1.7] SLF4J: See
http://www.slf4j.org/codes.html#version_mismatch for further details.
log4j:WARN No appenders could be found for logger (de.so.DemoSlf4j).
log4j:WARN Please initialize the log4j system properly.
When I use these dependencies, everything is fine. Look at the versions!
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version> <!-- or use LATEST -->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version> <!-- or use LATEST -->
</dependency>
</dependencies>
If you are using org.slf4j:slf4j-log4j12:1.7.21
instead of slf4j-simple
(what is more likely for production purposes), you'll get:
log4j:WARN No appenders could be found for logger (de.so.DemoSlf4j).
log4j:WARN Please initialize the log4j system properly. log4j:WARN See
http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
So do this:
- look in your project dependencies if there are other artifacts which have cascading dependencies to logging frameworks (log4j, slf4f, ...).
- check if your dependencies are proper deployed to your Tomcat. (.../WEB-INF/lib)
- check the versions