{"record":{"id":"ff5333dc8542d464","repo":"xuxueli/xxl-job","slug":"xxljobfileappender-appendlog-error-logfilename","errorCode":null,"errorMessage":"XxlJobFileAppender appendLog error, logFileName:{}","messagePattern":"XxlJobFileAppender appendLog error, logFileName:(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobFileAppender.java","lineNumber":115,"sourceCode":"\n\t/**\n\t * append log\n\t *\n\t * @param logFileName\tlog file name\n\t * @param appendLog\t\tappend log\n\t */\n\tpublic static void appendLog(String logFileName, String appendLog) {\n\n\t\t// valid\n\t\tif (StringTool.isBlank(logFileName) || appendLog == null) {\n\t\t\treturn;\n\t\t}\n\n\t\t// append log\n        try {\n            FileTool.writeLines(logFileName, List.of(appendLog), true);\n        } catch (IOException e) {\n            throw new RuntimeException(\"XxlJobFileAppender appendLog error, logFileName:\"+ logFileName, e);\n        }\n\t}\n\n\t/**\n\t * support read log-file\n\t *\n\t * @param logFileName\tlog file name\n\t * @param fromLineNum\tfrom line num\n\t * @return log content\n\t */\n\tpublic static LogData readLog(String logFileName, final int fromLineNum){\n\n\t\t// valid\n\t\tif (StringTool.isBlank(logFileName)) {\n            return new LogData(fromLineNum, 0, \"readLog fail, logFile not found\", true);\n\t\t}\n\t\tif (!FileTool.exists(logFileName)) {\n            return new LogData(fromLineNum, 0, \"readLog fail, logFile not exists\", true);","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/xuxueli/xxl-job/blob/e74c784f68f81fa89cb350913ef15794865d7b12/xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobFileAppender.java#L97-L133","documentation":"Thrown by XxlJobFileAppender.appendLog as a RuntimeException wrapping an IOException when FileTool.writeLines cannot append to the given log file. This fires on a real I/O failure during job-log writing; a blank fileName or null appendLog returns silently instead.","triggerScenarios":"appendLog(logFileName, appendLog) where the target .log file is not writable, the path is invalid, the file was deleted/moved mid-run, disk is full, or permissions changed after creation.","commonSituations":"Log rotation/deletion racing with an in-flight append; full disk; permission change on the log dir; long-running job whose log file was removed by the cleanup thread; path on an unreliable network mount.","solutions":["Verify the log directory remains writable and has free space for the job's lifetime.","Avoid external deletion of in-flight job log files; let the cleanup thread manage retention.","Move logs off network/fragile mounts onto local durable storage.","Increase disk capacity or shorten log retention if disk exhaustion is the cause."],"exampleFix":"// before: appendLog fails because the file was deleted externally\n// keep the file in place during the run; ensure writable dir + free space\n// after (caller guard): skip logging if path invalid rather than crash\ntry {\n    XxlJobFileAppender.appendLog(logFileName, line);\n} catch (RuntimeException io) {\n    logger.warn(\"job-log append failed for {}: {}\", logFileName, io.getMessage());\n}","handlingStrategy":"try-catch","validationCode":"// Best-effort: confirm the target file is writable before append\nFile f = new File(logFileName);\nif (f.getParentFile() == null || !f.getParentFile().canWrite()) {\n    log.warn(\"log file parent not writable: {}\", logFileName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    XxlJobFileAppender.appendLog(logFileName, line);\n} catch (RuntimeException e) {\n    // I/O failure mid-job; degrade gracefully instead of failing the job\n    logger.warn(\"job-log append failed for {}: {}\", logFileName, e.getMessage());\n}","preventionTips":["Keep log directories writable and with free disk for the job lifetime.","Do not externally delete in-flight job log files; rely on the cleanup thread.","Use local durable storage, not fragile network mounts, for logs."],"tags":["logging","filesystem","permissions","io","runtime"],"backgroundTag":null,"analyzedSha":"e74c784f68f81fa89cb350913ef15794865d7b12","analyzedAt":"2026-08-14T04:22:43.715Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}