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

Is it possible to have date/time in log file name. #242

Open
madelaney opened this issue Jan 26, 2022 · 9 comments
Open

Is it possible to have date/time in log file name. #242

madelaney opened this issue Jan 26, 2022 · 9 comments

Comments

@madelaney
Copy link

I was wondering if it was possible, when using a YAML configuration, to have the date/time inserted as the file name when configuring a file appender?

here is an example, where {d} would be a place holder for the datetime:

refresh_rate: 30 seconds
appenders:
  instance:
    kind: file
    path: "log/run-{d}.log"
root:
  level: info
  appends:
  - instance

/shrug

  • Mike D.
@ekafe
Copy link

ekafe commented Feb 18, 2022

I am also looking for the solution, did you figure our any solution.

@estk
Copy link
Owner

estk commented Apr 19, 2022

@madelaney this is not currently possible. I would be happy to mentor you if you would like to develop the feature.

@jporwal05
Copy link

Hi @estk ! I can pick this up under your mentorship.

@DenuxPlays
Copy link

Any updates on this?
This is like a key features for log-files

@puli1027
Copy link

Can anyone complete this function?

@Creative-Difficulty
Copy link

@estk Updates?

@DenuxPlays
Copy link

@estk Updates?

I Switched to tracing.
Here is my configuration:

https://github.com/financrr/financrr-app/blob/main/backend/backend/src/config/logger.rs

It's still not the bested (especially compared to logback what I use in all my Java projects) but it's good enough.

@aonyx45
Copy link

aonyx45 commented Apr 23, 2024

I'd definitely need this feature too. Would be gladly appreciated.

@TuEmb
Copy link

TuEmb commented May 27, 2024

I have a workaround for that at: https://github.com/TuEmb/log4rs

The format will be the same as chrono::datetime

    file:
        kind: file
        path: "log/file-{%Y-%m-%d_%H-%M-%S}.log"
        encoder:
            pattern: "[{d(%Y-%m-%dT%H:%M:%S%.6f)} {h({l}):<5.5} {M}] {m}{n}"

run example:
cargo run --example compile_time_config

output:
image

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

No branches or pull requests

9 participants