Skip to content

Conversation

@yhibo
Copy link

@yhibo yhibo commented Feb 6, 2026

Fixes: #3470

Motivation

On filesystems where std::fs::Metadata::created is unsupported, RollingFileAppender falls back to parsing the creation date from the log filename. However, PrimitiveDateTime::parse fails with InsufficientInformation for daily and weekly rotations because the filename lacks time components.

Solution

Replace the direct time::PrimitiveDateTime::parse call with a time::parsing::Parsed-based approach that defaults missing hour to midnight (00:00:00), allowing date-only filenames to be parsed successfully.

…imestamps

On filesystems where `std::fs::Metadata::created` is unsupported, `RollingFileAppender` falls back to parsing the creation
date from the log filename. However, `PrimitiveDateTime::parse` fails
with `InsufficientInformation` for daily and weekly rotations because
the filename lacks time components.

Replace the direct `time::PrimitiveDateTime::parse` call with a `time::parsing::Parsed`-based
approach that defaults missing hour to midnight (00:00:00), allowing
date-only filenames to be parsed successfully.

Fixes: tokio-rs#3470
@yhibo yhibo requested review from a team, hawkw and hds as code owners February 6, 2026 03:12
@dertin
Copy link

dertin commented Feb 6, 2026

Hey everyone, we’re affected by this issue on AWS EFS (NFSv4.1).

In our environment, std::fs::Metadata::created() is not available, so the appender falls back to parsing the timestamp from the log filename. With Rotation::DAILY, our filenames only include YYYY-MM-DD, which leads to a silent failure during parsing.

For reference, the filesystem is mounted as NFSv4.1 (EFS); we have something like:
nfs4 rw,vers=4.1,proto=tcp,hard,sec=sys

This setup reproduces the issue consistently. It resolves the problem for EFS/NFS environments where created() is unavailable, so it would be great to get it merged.

Thanks @yhibo for proposing the fix.

Added unit tests for parsing dates from log filenames with daily, hourly, and minutely rotations. Each test verifies that the correct timestamp is generated from the filename formats.
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

Successfully merging this pull request may close these issues.

RollingFileAppender fails to delete log files in certain file systems

3 participants