{"record":{"id":"b097075336079e2b","repo":"SonarSource/sonarqube","slug":"fail-to-load-the-logback-configuration","errorCode":null,"errorMessage":"Fail to load the Logback configuration: ","messagePattern":"Fail to load the Logback configuration: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sonar-core/src/main/java/org/sonar/core/config/Logback.java","lineNumber":61,"sourceCode":"\n  private Logback() {\n    // only statics\n  }\n\n  public static void configure(String classloaderPath, Map<String, String> substitutionVariables) {\n    InputStream input = Logback.class.getResourceAsStream(classloaderPath);\n    if (input == null) {\n      throw new IllegalArgumentException(\"Logback configuration not found in classloader: \" + classloaderPath);\n    }\n    configure(input, substitutionVariables);\n  }\n\n  public static void configure(File logbackFile, Map<String, String> substitutionVariables) {\n    try {\n      FileInputStream input = FileUtils.openInputStream(logbackFile);\n      configure(input, substitutionVariables);\n    } catch (IOException e) {\n      throw new IllegalArgumentException(\"Fail to load the Logback configuration: \" + logbackFile, e);\n    }\n  }\n\n  /**\n   * Note that this method closes the input stream\n   */\n  private static void configure(InputStream input, Map<String, String> substitutionVariables) {\n    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();\n    try {\n      JoranConfigurator configurator = new JoranConfigurator();\n      configurator.setContext(configureContext(lc, substitutionVariables));\n      configurator.doConfigure(input);\n    } catch (JoranException e) {\n      // StatusPrinter will handle this\n    } finally {\n      IOUtils.closeQuietly(input);\n    }\n    statusPrinter.printInCaseOfErrorsOrWarnings(lc);","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-core/src/main/java/org/sonar/core/config/Logback.java#L43-L79","documentation":"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.","triggerScenarios":"Calling Logback.configure(File, Map) with a File pointing to a nonexistent, unreadable, or non-regular file.","commonSituations":"Wrong SONARQUBE_HOME/conf path; logback.conf renamed or deleted; permission issues after install as another user.","solutions":["Check the logback file exists at the given path (Files.exists / ls)","Fix read permissions on the file","Pass the correct absolute path (e.g. $SONARQUBE_HOME/conf/logback.xml)","Inspect the wrapped IOException cause for details"],"exampleFix":"// before\nLogback.configure(new File(\"conf/logback.xml\"), vars);\n// after\nFile f = new File(home, \"conf/logback.xml\");\nif (f.isFile()) { Logback.configure(f, vars); }","handlingStrategy":"validation","validationCode":"java.io.File f = new java.io.File(path);\nif (!f.isFile() || !f.canRead()) {\n  throw new IllegalArgumentException(\"Logback file not readable: \" + f);\n}\nLogback.configure(f, vars);","typeGuard":null,"tryCatchPattern":"try {\n  Logback.configure(logbackFile, vars);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"Cannot load logback file {}\", logbackFile, e);\n}","preventionTips":["Resolve logback paths from SONARQUBE_HOME instead of relative paths","Check file existence and permissions before startup","Avoid renaming conf files during deployments"],"tags":["logging","configuration","file-io"],"backgroundTag":"file-open-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}