Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max_log_files does not work on some systems due to metadata.created() failure #3224

Open
szy1231 opened this issue Feb 25, 2025 · 1 comment

Comments

@szy1231
Copy link

szy1231 commented Feb 25, 2025

Version

tracing-appender = "0.2.3"

Platform

CentOS Linux 7

Crates

tracing-appender

Description

In prune_old_logs, the function currently uses:

/// Err(Error { kind: Unsupported, message: "creation time is not available on this platform currently" })
let created = metadata.created().ok()?;

However, metadata.created() is not available on all platforms or filesystems. On my system (CentOS with [3.10.0-1160.119.1.el7.x86_64]), it always fails, which prevents max_log_files(2) from working as expected, leading to excessive log retention.

Expected behavior:

Old logs should be pruned correctly according to max_log_files(2), even if metadata.created() is unavailable.

Actual behavior:

Logs are not deleted because metadata.created() returns an error, causing prune_old_logs to fail early.

Suggested Fix

If metadata.created() fails, the function should fall back to metadata.modified(). If both are unavailable, extracting the timestamp from the filename (if applicable) could serve as an additional fallback. This would prevent log pruning from failing entirely due to missing creation timestamps.

Would you be open to a PR implementing this fallback logic? I can submit a PR if needed.

@kaffarell
Copy link
Contributor

Should be fixed with #3000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants