Skip to content

tracing_appender file name without date for rolling logs #2701

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

Closed
incker opened this issue Aug 29, 2023 · 10 comments
Closed

tracing_appender file name without date for rolling logs #2701

incker opened this issue Aug 29, 2023 · 10 comments

Comments

@incker
Copy link

incker commented Aug 29, 2023

Hello!

It is more just a question.
Is it possible to write rolling logs to file that have name without date. Not debug.2023-08-29-09-32 but just debug

Forward thank you

@davidbarsky
Copy link
Member

There is no option for this at the moment. Out of curiosity, what behavior would you expect for older files that have since rolled over?

@incker
Copy link
Author

incker commented Sep 7, 2023

Older files can have date or other prefixes, it is Ok.
I just would like to customize current log file name. So i could read it with external program without loop all directory for searching current file.
Or make tail -f my_log_file for current log file without which name..
Mostly for external usage, and only for current log file

@ptdecker
Copy link

I'll second this request. One of our key clients (a major institution) expects the current log to always be named the same so that their log consolidation processes can pick it up nicely and that the older logs have the date postfix. Further, they would like them grouped by month and compressed (the older logs that is). The later is obviously a second request.

@davidbarsky
Copy link
Member

davidbarsky commented Oct 2, 2023

Thanks for explaining that, and I'm sorry for the delay in responding. The primary maintainers of this tracing (I'm including myself in this) don't really have a strong need for tracing-appender in their day jobs (e.g., folks at my employer log to stderr) and my personal opinion that advanced features like this should be handled by an external daemon. However, it's obvious that a demand for features like this exists.

I think we've been low on capacity to spend time on tracing-appender, and one of the challenges with requests like this one is that some requested toggles are non-composable with other options. This isn't a full proposal, but more of a vibe check: how would you feel if tracing_appender::rolling::RollingFileAppender exposed should_rotate and on_rotate closures (parameters and return types to be determined later) that allowed end-users to write the logic that determines file rotations or renaming themselves? If this this solution is acceptable, I'll write up an issue with a sketch that we'd be happy to merge.

@ptdecker
Copy link

ptdecker commented Oct 2, 2023

@davidbarsky I think exposing a should_rotate and on_rotate closures would be great. Then each of us can implement the behavior needed including proper file naming and handling of the rotated logs (including things like compressing them if needed, etc.). One thing that is important is that the current log not have the appended date. It really causes problems for our DevOps folks with the log name changing every day. So, if there was some way to make sure RollingFileAppender didn't append that date to the current day's log and you added the closures my needs (selfishly) would be met. THANK YOU for considering these updates

@brian030128
Copy link
Contributor

@davidbarsky this sounds pretty nice! I could help implement it when the sketch is out.

@brian030128
Copy link
Contributor

@davidbarsky Or I could open an issue and write a simple sketch first?

@incker
Copy link
Author

incker commented Oct 15, 2023

You could easilly write your implementation of write to file,
then wrap it into NonBlocking struct from tracing_appender and that will work pretty good
For me it was the best solution. I think I will close this issue, as I have opened it

@incker incker closed this as completed Oct 15, 2023
@ptdecker
Copy link

That's a one approach that would work @incker , but perhaps not as clean as what @davidbarsky proposed and @SpeedReach offerred to help with. I would have kept this open for them to work under but perhaps they will create their own ticket now for their approach.

@davidbarsky
Copy link
Member

@davidbarsky Or I could open an issue and write a simple sketch first?

Sorry for the delay. I'll open an issue with those details later today.

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

4 participants