{"record":{"id":"917b2eb3cc77ffeb","repo":"SonarSource/sonarqube","slug":"logback-configuration-not-found-in-classloader","errorCode":null,"errorMessage":"Logback configuration not found in classloader: ","messagePattern":"Logback configuration not found in classloader: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sonar-core/src/main/java/org/sonar/core/config/Logback.java","lineNumber":51,"sourceCode":"import org.slf4j.LoggerFactory;\n\n/**\n * Configure Logback\n *\n * @since 2.12\n */\npublic class Logback {\n\n  private static final StatusPrinter2 statusPrinter = new StatusPrinter2();\n\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();","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-core/src/main/java/org/sonar/core/config/Logback.java#L33-L69","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify the logback configuration resource exists on the classpath at the exact given path","Correct the classloaderPath string (leading slash, spelling)","Add the logback file to the jar/classpath that loads it"],"exampleFix":"// before\nLogback.configure(\"/conf/logback-custom.xml\", vars);\n// after\nLogback.configure(\"/logback-custom.xml\", vars); // resource actually packaged at root","handlingStrategy":"validation","validationCode":"if (Logback.class.getResourceAsStream(classloaderPath) == null) {\n  throw new IllegalArgumentException(\"Resource missing on classpath: \" + classloaderPath);\n}\nLogback.configure(classloaderPath, vars);","typeGuard":null,"tryCatchPattern":"try {\n  Logback.configure(path, vars);\n} catch (IllegalArgumentException e) {\n  LOG.warn(\"Logback config missing, using default\", e);\n  Logback.configure(\"/logback.xml\", vars);\n}","preventionTips":["Verify resource path with getResourceAsStream before configuring","Keep logback resources packaged in the same jar as the boot code","Use constants for resource paths to avoid typos"],"tags":["logging","classpath","configuration"],"backgroundTag":"config-file-not-found","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"}