{"record":{"id":"d70c22a068cf9586","repo":"OpenFeign/feign","slug":"could-not-add-file-handler","errorCode":null,"errorMessage":"Could not add file handler.","messagePattern":"Could not add file handler\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/feign/Logger.java","lineNumber":266,"sourceCode":"    /**\n     * Helper that configures java.util.logging to sanely log messages at FINE level without\n     * additional formatting.\n     */\n    public JavaLogger appendToFile(String logfile) {\n      logger.setLevel(java.util.logging.Level.FINE);\n      try {\n        FileHandler handler = new FileHandler(logfile, true);\n        handler.setFormatter(\n            new SimpleFormatter() {\n              @Override\n              public String format(LogRecord record) {\n                return String.format(\"%s%n\", record.getMessage()); // NOPMD\n              }\n            });\n        logger.addHandler(handler);\n        handlers.add(handler);\n      } catch (IOException e) {\n        throw new IllegalStateException(\"Could not add file handler.\", e);\n      }\n      return this;\n    }\n\n    @Override\n    public void close() {\n      for (Handler handler : handlers) {\n        logger.removeHandler(handler);\n        handler.close();\n      }\n      handlers.clear();\n    }\n  }\n\n  public static class NoOpLogger extends Logger {\n\n    @Override\n    protected void logRequest(String configKey, Level logLevel, Request request) {}","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/core/src/main/java/feign/Logger.java#L248-L284","documentation":"Logged/raised by Logger.JavaLogger.appendToFile when constructing a java.util.logging FileHandler for the given logfile path fails — the path is unwritable, its directory does not exist, or the file is locked by another process. It is a configuration guard for log setup: the input at fault is the logfile path string passed to appendToFile, not the HTTP traffic being logged.","triggerScenarios":"Thrown at core/src/main/java/feign/Logger.java:266 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the log file's parent directory exists and the process has write permissions on it","Use an absolute path or one relative to the working directory that is valid at runtime","Close or avoid sharing the same log file with another concurrently running process (FileHandler locks its target)","If file logging is unavailable, fall back to Logger.Level and console/jdk logging via the default JavaLogger constructor"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e2a1e27560a1e68840c34f031afca88b36096e30","analyzedAt":"2026-09-10T12:37:37.238Z","contentChangedAt":"2026-09-10T12:37:37.238Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}