Issue
The Java project is using log4j2, but some components are using SLF4J logging and caused the following error message:
1 | SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". |
Solution
To fix it, we need a SLF4J Bridge. Puts log4j-slf4j-impl in the classpath.
1 | <dependency> |
Issue: No output
There could a problem if you don’t put the log4j2.xml in class path.
The default log level is error.
You can use logger.error
and logger.info
to log a message. And the log4j2.xml is not in correct path if the error message is printed only.
Solution
You can put the log4j2.xml in src/main/resources, which is in classpath.