SonarSource/sonarqube · error · IllegalArgumentException

Fail to load the Logback configuration:

Error message

Fail to load the Logback configuration: 

What it means

The File-based overload of Logback.configure opens the given logback file with FileUtils.openInputStream; if an IOException occurs (file missing, unreadable, is a directory), it throws IllegalArgumentException including the file path.

Solutions

  1. Check the logback file exists at the given path (Files.exists / ls)
  2. Fix read permissions on the file
  3. Pass the correct absolute path (e.g. $SONARQUBE_HOME/conf/logback.xml)
  4. Inspect the wrapped IOException cause for details

Example fix

// before
Logback.configure(new File("conf/logback.xml"), vars);
// after
File f = new File(home, "conf/logback.xml");
if (f.isFile()) { Logback.configure(f, vars); }
Defensive patterns

Strategy: validation

Validate before calling

java.io.File f = new java.io.File(path);
if (!f.isFile() || !f.canRead()) {
  throw new IllegalArgumentException("Logback file not readable: " + f);
}
Logback.configure(f, vars);

Try / catch

try {
  Logback.configure(logbackFile, vars);
} catch (IllegalArgumentException e) {
  LOG.error("Cannot load logback file {}", logbackFile, e);
}

Prevention

When it happens

Trigger: Calling Logback.configure(File, Map) with a File pointing to a nonexistent, unreadable, or non-regular file.

Common situations: Wrong SONARQUBE_HOME/conf path; logback.conf renamed or deleted; permission issues after install as another user.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


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

Appendix: source

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

  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();
    try {
      JoranConfigurator configurator = new JoranConfigurator();
      configurator.setContext(configureContext(lc, substitutionVariables));
      configurator.doConfigure(input);
    } catch (JoranException e) {
      // StatusPrinter will handle this
    } finally {
      IOUtils.closeQuietly(input);
    }
    statusPrinter.printInCaseOfErrorsOrWarnings(lc);

View on GitHub (pinned to 184c821202)