xuxueli/xxl-job · error · RuntimeException

XxlJobFileAppender appendLog error, logFileName:{}

Error message

XxlJobFileAppender appendLog error, logFileName:{}

What it means

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.

Source

Thrown at xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobFileAppender.java:115

	/**
	 * append log
	 *
	 * @param logFileName	log file name
	 * @param appendLog		append log
	 */
	public static void appendLog(String logFileName, String appendLog) {

		// valid
		if (StringTool.isBlank(logFileName) || appendLog == null) {
			return;
		}

		// append log
        try {
            FileTool.writeLines(logFileName, List.of(appendLog), true);
        } catch (IOException e) {
            throw new RuntimeException("XxlJobFileAppender appendLog error, logFileName:"+ logFileName, e);
        }
	}

	/**
	 * support read log-file
	 *
	 * @param logFileName	log file name
	 * @param fromLineNum	from line num
	 * @return log content
	 */
	public static LogData readLog(String logFileName, final int fromLineNum){

		// valid
		if (StringTool.isBlank(logFileName)) {
            return new LogData(fromLineNum, 0, "readLog fail, logFile not found", true);
		}
		if (!FileTool.exists(logFileName)) {
            return new LogData(fromLineNum, 0, "readLog fail, logFile not exists", true);

View on GitHub (pinned to e74c784f68)

Solutions

  1. Verify the log directory remains writable and has free space for the job's lifetime.
  2. Avoid external deletion of in-flight job log files; let the cleanup thread manage retention.
  3. Move logs off network/fragile mounts onto local durable storage.
  4. Increase disk capacity or shorten log retention if disk exhaustion is the cause.

Example fix

// before: appendLog fails because the file was deleted externally
// keep the file in place during the run; ensure writable dir + free space
// after (caller guard): skip logging if path invalid rather than crash
try {
    XxlJobFileAppender.appendLog(logFileName, line);
} catch (RuntimeException io) {
    logger.warn("job-log append failed for {}: {}", logFileName, io.getMessage());
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Best-effort: confirm the target file is writable before append
File f = new File(logFileName);
if (f.getParentFile() == null || !f.getParentFile().canWrite()) {
    log.warn("log file parent not writable: {}", logFileName);
}

Try / catch

try {
    XxlJobFileAppender.appendLog(logFileName, line);
} catch (RuntimeException e) {
    // I/O failure mid-job; degrade gracefully instead of failing the job
    logger.warn("job-log append failed for {}: {}", logFileName, e.getMessage());
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of xuxueli/xxl-job@e74c784f68 (2026-08-14). Data as JSON: /api/errors/ff5333dc8542d464. Report an issue: GitHub.