{"record":{"id":"afc3b7290da72859","repo":"apache/maven","slug":"unable-to-redirect-logging-to-logfile","errorCode":null,"errorMessage":"Unable to redirect logging to ${logFile}","messagePattern":"Unable to redirect logging to (.+?)","errorType":"exception","errorClass":"MavenException","httpStatus":null,"severity":"error","filePath":"impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java","lineNumber":425,"sourceCode":"        // no need to set them back, this is already handled by MessageUtils.systemUninstall() above\n    }\n\n    protected Consumer<String> determineWriter(C context) {\n        if (context.writer == null) {\n            context.writer = doDetermineWriter(context);\n        }\n        return context.writer;\n    }\n\n    protected Consumer<String> doDetermineWriter(C context) {\n        if (context.options().logFile().isPresent()) {\n            Path logFile = context.cwd.resolve(context.options().logFile().get());\n            try {\n                PrintWriter printWriter = new PrintWriter(Files.newBufferedWriter(logFile), true);\n                context.closeables.add(printWriter);\n                return printWriter::println;\n            } catch (IOException e) {\n                throw new MavenException(\"Unable to redirect logging to \" + logFile, e);\n            }\n        } else {\n            // Given the terminal creation has been offloaded to a different thread,\n            // do not pass directly the terminal writer\n            return msg -> {\n                PrintWriter pw = context.terminal.writer();\n                pw.println(msg);\n                pw.flush();\n            };\n        }\n    }\n\n    protected void activateLogging(C context) throws Exception {\n        if (!SLF4JBridgeHandler.isInstalled()) {\n            SLF4JBridgeHandler.removeHandlersForRootLogger();\n            SLF4JBridgeHandler.install();\n        }\n","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java#L407-L443","documentation":"Error \"Unable to redirect logging to ${logFile}\" thrown in apache/maven.","triggerScenarios":"Thrown at impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java:425 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}