After moving from JDK8 to JDK11 I get "SLF4J: No SLF4J providers were found" and not logging. Using Maven and IntelliJ.
Output:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
In JDK8 I had these in the pom.xml and it all worked very well.
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.7</version>
</dependency>
I looking around and followed a tip and added slf4j18-impl but I still have the same problem. This is is how it looks in the pom.xml right now:
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j18-impl</artifactId>
<version>2.18.0</version>
</dependency>
And this kind of code did work in JDK8 but not in JDK11
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestOutput {
private static final Logger LOG = LoggerFactory.getLogger(TestOutput.class);
public static void tryToLog() {
LOG.info("Hello world!");
}
}