zed-industries/zed · error

Log file rotation failed. Truncating log file anyways: {err}

Error message

Log file rotation failed. Truncating log file anyways: {err}

What it means

rotate_log_file could not rotate the current log file (e.g. copy to the rotated path failed) but the log is truncated anyway; the message records the rotation error while continuing, so old log contents may be lost.

Source

Thrown at crates/zlog/src/sink.rs:272

        }
        f.write_char(']')?;
        Ok(())
    }
}

fn rotate_log_file<PathRef>(
    path: Option<PathRef>,
    path_rotate: Option<PathRef>,
) -> std::io::Result<Option<fs::File>>
where
    PathRef: AsRef<std::path::Path>,
{
    let path = path.as_ref().map(PathRef::as_ref);
    let rotation_error = match (path, path_rotate) {
        (Some(_), None) => Some(anyhow::anyhow!("No rotation log file path configured")),
        (None, _) => Some(anyhow::anyhow!("No log file path configured")),
        (Some(path), Some(path_rotate)) => fs::copy(path, path_rotate)
            .err()
            .map(|err| anyhow::anyhow!(err)),
    };
    if let Some(err) = rotation_error {
        eprintln!("Log file rotation failed. Truncating log file anyways: {err}",);
    }
    path.map(|path| {
        fs::OpenOptions::new()
            .create(true)
            .write(true)
            .truncate(true)
            .open(path)
    })
    .transpose()
}

#[cfg(test)]
mod tests {

View on GitHub (pinned to f4178619ac)

Solutions

  1. Check disk space and permissions on the log/rotation directories
  2. Ensure no other process holds the log file locked
  3. Consider keeping the file untruncated when rotation fails
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/zlog/src/sink.rs:272 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/f7627f74ddc8a461. Report an issue: GitHub.