SLF4J doesn’t find provider from logback-classic on vertx

I’m trying to add Logback on a Vertx project, but it seems SLF4J can’t see logback even if itself come from a logback dependency. I used maven dependency logback-classic, which transitively imports slf4j-api and logback-core.

When I run a simple main class with random log I have the following error:

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.

My pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>vertx-stock-broker</artifactId>
  <version>1.0.0-SNAPSHOT</version>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
    <maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
    <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
    <exec-maven-plugin.version>3.0.0</exec-maven-plugin.version>

    <vertx.version>4.5.11</vertx.version>
    <logback-classic.version>1.5.12</logback-classic.version>
    <junit-jupiter.version>5.9.1</junit-jupiter.version>

    <main.verticle>com.example.vertx_stock_broker.MainVerticle</main.verticle>
    <launcher.class>io.vertx.core.Launcher</launcher.class>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-stack-depchain</artifactId>
        <version>${vertx.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-web</artifactId>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>${logback-classic.version}</version>
    </dependency>

    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>${junit-jupiter.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>${junit-jupiter.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <configuration>
          <release>17</release>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <version>${maven-shade-plugin.version}</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer
                  implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <manifestEntries>
                    <Main-Class>${launcher.class}</Main-Class>
                    <Main-Verticle>${main.verticle}</Main-Verticle>
                  </manifestEntries>
                </transformer>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
              </transformers>
              <outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar
              </outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>${exec-maven-plugin.version}</version>
        <configuration>
          <mainClass>${launcher.class}</mainClass>
          <arguments>
            <argument>run</argument>
            <argument>${main.verticle}</argument>
          </arguments>
        </configuration>
      </plugin>
    </plugins>
  </build>


</project>

The running class:

package com.example.vertx_stock_broker;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Test {
  private static final Logger LOG = LoggerFactory.getLogger(Test.class);

  public static void main(String[] args) {
    LOG.debug("debug");
    LOG.info("info");
    LOG.error("error");
  }
}

I run it with the IntelliJ run tool which silently run (I have shorten paths with ‘…’):

openjdk-22.0.2binjava.exe "-javaagent:...IntelliJ IDEA 2024.2.3libidea_rt.jar=64366:...IntelliJ IDEA 2024.2.3bin" 
-Dfile.encoding=UTF-8 
-Dsun.stdout.encoding=UTF-8 
-Dsun.stderr.encoding=UTF-8 
-classpath ...vertx-stock-brokertargetclasses;
    ....m2repositoryiovertxvertx-web4.5.11vertx-web-4.5.11.jar;
    ....m2repositoryiovertxvertx-web-common4.5.11vertx-web-common-4.5.11.jar;
    ....m2repositoryiovertxvertx-auth-common4.5.11vertx-auth-common-4.5.11.jar;
    ....m2repositoryiovertxvertx-bridge-common4.5.11vertx-bridge-common-4.5.11.jar;
    ....m2repositoryiovertxvertx-core4.5.11vertx-core-4.5.11.jar;
    ....m2repositoryionettynetty-common4.1.115.Finalnetty-common-4.1.115.Final.jar;
    ....m2repositoryionettynetty-buffer4.1.115.Finalnetty-buffer-4.1.115.Final.jar;
    ....m2repositoryionettynetty-transport4.1.115.Finalnetty-transport-4.1.115.Final.jar;
    ....m2repositoryionettynetty-handler4.1.115.Finalnetty-handler-4.1.115.Final.jar;
    ....m2repositoryionettynetty-transport-native-unix-common4.1.115.Finalnetty-transport-native-unix-common-4.1.115.Final.jar;
    ....m2repositoryionettynetty-codec4.1.115.Finalnetty-codec-4.1.115.Final.jar;
    ....m2repositoryionettynetty-handler-proxy4.1.115.Finalnetty-handler-proxy-4.1.115.Final.jar;
    ....m2repositoryionettynetty-codec-socks4.1.115.Finalnetty-codec-socks-4.1.115.Final.jar;
    ....m2repositoryionettynetty-codec-http4.1.115.Finalnetty-codec-http-4.1.115.Final.jar;
    ....m2repositoryionettynetty-codec-http24.1.115.Finalnetty-codec-http2-4.1.115.Final.jar;
    ....m2repositoryionettynetty-resolver4.1.115.Finalnetty-resolver-4.1.115.Final.jar;
    ....m2repositoryionettynetty-resolver-dns4.1.115.Finalnetty-resolver-dns-4.1.115.Final.jar;
    ....m2repositoryionettynetty-codec-dns4.1.115.Finalnetty-codec-dns-4.1.115.Final.jar;
    ....m2repositorycomfasterxmljacksoncorejackson-core2.16.1jackson-core-2.16.1.jar;
    ....m2repositorychqoslogbacklogback-core1.5.12logback-core-1.5.12.jar;
    ....m2repositoryorgslf4jslf4j-api2.0.7slf4j-api-2.0.7.jar com.example.vertx_stock_broker.MainVerticle

My logback.xml file:

<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <root level="debug">
    <appender-ref ref="STDOUT" />
  </root>
</configuration>

I didn’t find any dependencies conflict or duplication. OpenJdk22 is used.

I expect to get logback logs at runtime

Edit:

Thanks to @Ceki answer, it appear that the problem was with IntelliJ, the logback-classic jar was not provided in the classpath generated run command, after an IntelliJ cache clean and a restart the problem was solved. Now logback-classic is provided in classpath and it work as expected.

New contributor

Mickael Alvarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

2

FYI, logback-classic.jar is the slf4j provider not logback-core.jar. The former seems to be missing from the class path of InterlliJ Idea that you provided.

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật