SonarSource/sonarqube · error · IllegalArgumentException

Logback configuration not found in classloader:

Error message

Logback configuration not found in classloader: 

What it means

SonarQube configures Logback logging by loading a logback XML from the classpath. If getResourceAsStream returns null for the given classloader path, an IllegalArgumentException is thrown with the path appended.

Solutions

  1. Verify the logback configuration resource exists on the classpath at the exact given path
  2. Correct the classloaderPath string (leading slash, spelling)
  3. Add the logback file to the jar/classpath that loads it

Example fix

// before
Logback.configure("/conf/logback-custom.xml", vars);
// after
Logback.configure("/logback-custom.xml", vars); // resource actually packaged at root
Defensive patterns

Strategy: validation

Validate before calling

if (Logback.class.getResourceAsStream(classloaderPath) == null) {
  throw new IllegalArgumentException("Resource missing on classpath: " + classloaderPath);
}
Logback.configure(classloaderPath, vars);

Try / catch

try {
  Logback.configure(path, vars);
} catch (IllegalArgumentException e) {
  LOG.warn("Logback config missing, using default", e);
  Logback.configure("/logback.xml", vars);
}

Prevention

When it happens

Trigger: Calling Logback.configure(classloaderPath, variables) with a path string that has no matching resource on the classpath (e.g. "/logback.xml" typo'd or not packaged).

Common situations: Custom logback file name that is not on the classpath; running in a stripped deployment where the logback resource was excluded; typo in resource path.

Understand the failure class

Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/917b2eb3cc77ffeb. Report an issue: GitHub.

Appendix: source

Thrown at sonar-core/src/main/java/org/sonar/core/config/Logback.java:51

import org.slf4j.LoggerFactory;

/**
 * Configure Logback
 *
 * @since 2.12
 */
public class Logback {

  private static final StatusPrinter2 statusPrinter = new StatusPrinter2();

  private Logback() {
    // only statics
  }

  public static void configure(String classloaderPath, Map<String, String> substitutionVariables) {
    InputStream input = Logback.class.getResourceAsStream(classloaderPath);
    if (input == null) {
      throw new IllegalArgumentException("Logback configuration not found in classloader: " + classloaderPath);
    }
    configure(input, substitutionVariables);
  }

  public static void configure(File logbackFile, Map<String, String> substitutionVariables) {
    try {
      FileInputStream input = FileUtils.openInputStream(logbackFile);
      configure(input, substitutionVariables);
    } catch (IOException e) {
      throw new IllegalArgumentException("Fail to load the Logback configuration: " + logbackFile, e);
    }
  }

  /**
   * Note that this method closes the input stream
   */
  private static void configure(InputStream input, Map<String, String> substitutionVariables) {
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

View on GitHub (pinned to 184c821202)