I have a trivial application which is using version 3.6.1 of the Quarkus framework.
package net.example.dashboard.dbcli;
import org.slf4j.*;
import io.quarkus.runtime.Startup;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;
@Startup
@ApplicationScoped
public class Main {
final Logger logger = LoggerFactory.getLogger(Main.class);
@PostConstruct
public void init() {
System.out.println("App started");
logger.error("Logger says hello");
}
}
If I run the built application in the JVM it works are expected: I see the text printed to the console, and I see my logger output displayed as well as some log output from the framework itself.
$ java -jar target/quarkus-app/quarkus-run.jar
App started
2024-02-04 18:21:15,701 ERROR [net.exa.das.dbc.Main] (main) Logger says hello
2024-02-04 18:21:15,715 INFO [io.quarkus] (main) dbcli 1.0.0 on JVM (powered by Quarkus 3.6.1) started in 0.768s.
2024-02-04 18:21:15,719 INFO [io.quarkus] (main) Profile prod activated.
2024-02-04 18:21:15,719 INFO [io.quarkus] (main) Installed features: [cdi]
However when I run the application native image, I see messages indicating that no SLF4J provider was found, and I do not see my logger output.
$ target/dbcli
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.
App started
2024-02-04 18:17:41,741 INFO [io.quarkus] (main) dbcli 1.0.0 native (powered by Quarkus 3.6.1) started in 0.030s.
2024-02-04 18:17:41,741 INFO [io.quarkus] (main) Profile prod activated.
2024-02-04 18:17:41,741 INFO [io.quarkus] (main) Installed features: [cdi]
It seems like the application was using SLF4Jv1 but the provider is SLF4Jv2, although I am not able to prove this.
Has anyone encountered this before, or may could provide me some clues on how to better understand what is happening?
My platform is:
OS: Oracle Linux 8
Java: OpenJDK 21.0.2+13-LTS
GraalVM: Mandrel-23.1.2.0-Final (runs in container)
Podman 4.0.2 (rootless)
pom.xml:
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>net.example.dashboard</groupId>
<artifactId>dbcli</artifactId>
<version>1.0.0</version>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>3.6.1</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.6.1</quarkus.platform.version>
<quarkus.package.output-name>dbcli</quarkus.package.output-name>
<quarkus.package.add-runner-suffix>false</quarkus.package.add-runner-suffix>
<quarkus.package.type>native</quarkus.package.type>
<quarkus.banner.enabled>false</quarkus.banner.enabled>
<quarkus.log.level>INFO</quarkus.log.level>
<quarkus.log.console.enable>true</quarkus.log.console.enable>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<release>21</release>
</configuration>
</plugin>
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Also posted here: Quarkus Development User Chat
Adding maven dependency tree:
[INFO] --- dependency:3.6.0:tree (default-cli) @ dbcli ---
[INFO] net.example.dashboard:dbcli:jar:1.0.0
[INFO] \- io.quarkus:quarkus-arc:jar:3.6.1:compile
[INFO] +- io.quarkus.arc:arc:jar:3.6.1:compile
[INFO] | +- jakarta.enterprise:jakarta.enterprise.cdi-api:jar:4.0.1:compile
[INFO] | | +- jakarta.enterprise:jakarta.enterprise.lang-model:jar:4.0.1:compile
[INFO] | | +- jakarta.el:jakarta.el-api:jar:5.0.1:compile
[INFO] | | \- jakarta.interceptor:jakarta.interceptor-api:jar:2.1.0:compile
[INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:2.1.1:compile
[INFO] | +- jakarta.transaction:jakarta.transaction-api:jar:2.0.1:compile
[INFO] | +- io.smallrye.reactive:mutiny:jar:2.5.1:compile
[INFO] | | \- io.smallrye.common:smallrye-common-annotation:jar:2.1.2:compile
[INFO] | \- org.jboss.logging:jboss-logging:jar:3.5.3.Final:compile
[INFO] +- io.quarkus:quarkus-core:jar:3.6.1:compile
[INFO] | +- jakarta.inject:jakarta.inject-api:jar:2.0.1:compile
[INFO] | +- io.smallrye.common:smallrye-common-os:jar:2.1.2:compile
[INFO] | +- io.quarkus:quarkus-ide-launcher:jar:3.6.1:compile
[INFO] | +- io.quarkus:quarkus-development-mode-spi:jar:3.6.1:compile
[INFO] | +- io.smallrye.config:smallrye-config:jar:3.4.4:compile
[INFO] | | \- io.smallrye.config:smallrye-config-core:jar:3.4.4:compile
[INFO] | | +- org.eclipse.microprofile.config:microprofile-config-api:jar:3.0.3:compile
[INFO] | | +- io.smallrye.common:smallrye-common-classloader:jar:2.1.2:compile
[INFO] | | \- io.smallrye.config:smallrye-config-common:jar:3.4.4:compile
[INFO] | +- org.jboss.logmanager:jboss-logmanager:jar:3.0.2.Final:compile
[INFO] | | +- io.smallrye.common:smallrye-common-constraint:jar:2.1.2:compile
[INFO] | | +- io.smallrye.common:smallrye-common-cpu:jar:2.1.2:compile
[INFO] | | +- io.smallrye.common:smallrye-common-expression:jar:2.1.2:compile
[INFO] | | | \- io.smallrye.common:smallrye-common-function:jar:2.1.2:compile
[INFO] | | +- io.smallrye.common:smallrye-common-net:jar:2.1.2:compile
[INFO] | | +- io.smallrye.common:smallrye-common-ref:jar:2.1.2:compile
[INFO] | | +- jakarta.json:jakarta.json-api:jar:2.1.3:compile
[INFO] | | \- org.eclipse.parsson:parsson:jar:1.1.5:compile
[INFO] | +- org.jboss.logging:jboss-logging-annotations:jar:2.2.1.Final:compile
[INFO] | +- org.jboss.threads:jboss-threads:jar:3.5.1.Final:compile
[INFO] | +- org.slf4j:slf4j-api:jar:2.0.6:compile
[INFO] | +- org.jboss.slf4j:slf4j-jboss-logmanager:jar:2.0.0.Final:compile
[INFO] | +- org.wildfly.common:wildfly-common:jar:1.7.0.Final:compile
[INFO] | +- io.quarkus:quarkus-bootstrap-runner:jar:3.6.1:compile
[INFO] | | +- io.smallrye.common:smallrye-common-io:jar:2.1.2:compile
[INFO] | | \- io.github.crac:org-crac:jar:0.1.3:compile
[INFO] | \- io.quarkus:quarkus-fs-util:jar:0.0.9:compile
[INFO] \- org.eclipse.microprofile.context-propagation:microprofile-context-propagation-api:jar:1.3:compile
The "SLF4J: No SLF4J providers were found" message indicates slf4j-api version 2.0 or later is in use. You need to place a compatible provider on your class path, for example, logback version 1.3 or later.