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

how to append a string on the end of a rolling file. #3188

Open
imgoby opened this issue Jan 7, 2025 · 0 comments
Open

how to append a string on the end of a rolling file. #3188

imgoby opened this issue Jan 7, 2025 · 0 comments

Comments

@imgoby
Copy link

imgoby commented Jan 7, 2025

Use the following code to generate a log file every day, for example, when the date is from January 7, 2025 to January 8, 2025, how to append a string after the file log.log.2025-01-07, such as: “-----file end------”



let file_appender = tracing_appender::rolling::daily("logs", "log.log");
let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);

  let file_layer = fmt::layer()
        .with_ansi(false)
        .with_file(false)
        .with_line_number(true)
        .with_thread_ids(false)
        .with_thread_names(true)
        .with_timer(LocalTimer)
        .with_writer(non_blocking)
        .with_filter(LevelFilter::INFO);


        let collector = tracing_subscriber::registry()
        .with(file_layer)
        .with(std_layer);


        tracing::subscriber::set_global_default(collector).expect("Tracing collect error");
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

1 participant