Skip to content

Give more control over file names in tracing-appender #1477

Closed
@SadiinsoSnowfall

Description

@SadiinsoSnowfall

Feature Request

Crates

This concerns the tracing-appender crate.

Motivation

Add more control over the resulting file name(s) when using tracing-appender. In some case, it can be better to have all log files ends with the same extension (.log for example) which is currently not possible achieve with tracig-appender as the crate create file names with a date appended at the end and the user can only control the file prefix (example: logs_directory/log_file_name_prefix.yyyy-MM-dd-HH-mm).

Proposal

a) Add a way to set a suffix for file names, similar to how the prefix work.
or
b) Add a way to set a custom formatter for file names, which would take parameters such as the date to include and return a file name to use for example :

let appender = tracing_appender::rolling::daily("/var/log/", |date| {
    format!("app_name.{:?}.log", date)
});

(this is only an example, an implementation of this feature could use a new "constructor" function to avoid creating a breaking change)

Metadata

Metadata

Assignees

No one assigned

    Labels

    crate/appenderRelated to the `tracing-appender` crate.kind/featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions