{"record":{"id":"f7627f74ddc8a461","repo":"zed-industries/zed","slug":"log-file-rotation-failed-truncating-log-file-anyw","errorCode":null,"errorMessage":"Log file rotation failed. Truncating log file anyways: {err}","messagePattern":"Log file rotation failed\\. Truncating log file anyways: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zlog/src/sink.rs","lineNumber":272,"sourceCode":"        }\n        f.write_char(']')?;\n        Ok(())\n    }\n}\n\nfn rotate_log_file<PathRef>(\n    path: Option<PathRef>,\n    path_rotate: Option<PathRef>,\n) -> std::io::Result<Option<fs::File>>\nwhere\n    PathRef: AsRef<std::path::Path>,\n{\n    let path = path.as_ref().map(PathRef::as_ref);\n    let rotation_error = match (path, path_rotate) {\n        (Some(_), None) => Some(anyhow::anyhow!(\"No rotation log file path configured\")),\n        (None, _) => Some(anyhow::anyhow!(\"No log file path configured\")),\n        (Some(path), Some(path_rotate)) => fs::copy(path, path_rotate)\n            .err()\n            .map(|err| anyhow::anyhow!(err)),\n    };\n    if let Some(err) = rotation_error {\n        eprintln!(\"Log file rotation failed. Truncating log file anyways: {err}\",);\n    }\n    path.map(|path| {\n        fs::OpenOptions::new()\n            .create(true)\n            .write(true)\n            .truncate(true)\n            .open(path)\n    })\n    .transpose()\n}\n\n#[cfg(test)]\nmod tests {\n","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/zlog/src/sink.rs#L254-L290","documentation":"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.","triggerScenarios":"Thrown at crates/zlog/src/sink.rs:272 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space and permissions on the log/rotation directories","Ensure no other process holds the log file locked","Consider keeping the file untruncated when rotation fails"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}