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

log rotate file name postfix can be formatted? #9287

Open
riverlee2014 opened this issue Nov 27, 2020 · 6 comments
Open

log rotate file name postfix can be formatted? #9287

riverlee2014 opened this issue Nov 27, 2020 · 6 comments
Labels
theme/operator-usability Replaces UX. Anything related to making things easier for the practitioner type/enhancement Proposed improvement or new feature type/question Not an "enhancement" or "bug". Please post on discuss.hashicorp

Comments

@riverlee2014
Copy link

I have use log rotate configuration, but log file name is end with number, It's hard to find the target file.

"log_level": "INFO",
"log_file": "logs/info.log",
"log_rotate_max_files": 15,

Is there any format config parameter?

info-1606459202259806039.log
info-1606372739843526258.log
info-1606286280091474531.log
info-1606197194984836618.log
info-1606110075297491022.log
@jsosulska jsosulska added type/enhancement Proposed improvement or new feature type/question Not an "enhancement" or "bug". Please post on discuss.hashicorp labels Dec 11, 2020
@jsosulska
Copy link
Contributor

Hi @riverlee2014 ,

Can you explain more abut your usecase? What format would you want there? I don't think this is a big ask, and I could see how wanting a more readable time/date format might be nice, but I'm curious of the application.

Best,
Jono

@riverlee2014
Copy link
Author

Hi, @jsosulska ,
We hope quick check the date log. But log file rotate format as these postfix number :

info-1606459202259806039.log
info-1606372739843526258.log
info-1606286280091474531.log
info-1606197194984836618.log
info-1606110075297491022.log

It makes us confused which one corresponds to which day?
Can be configured as a format option like this:

"log_file" : "/var/log/consul-{YYYY-MM-dd}.log"

So the log file names make it fast to read in human format.

Thank you!

@jkirschner-hashicorp
Copy link
Contributor

It certainly would be better to have a more direct option to see a human readable date, but a potential workaround for anyone with this same question to consider in the meantime:

View the file creation time for all the files, e.g.,:

$ ls --full-time /path/to/consul/logs
-rw-r--r-- 1 consul    consul     3568 2020-11-27 06:40:02.259000000 -0400 info-1606459202259806039.log
...

@jkirschner-hashicorp jkirschner-hashicorp added the theme/operator-usability Replaces UX. Anything related to making things easier for the practitioner label Aug 19, 2021
@jkirschner-hashicorp
Copy link
Contributor

Hi @riverlee2014,

The Unix timestamp currently has nanosecond resolution to prevent filename conflicts. We'd want to do something similar with a human-readable timestamp.

It could like something like this:
log-${time.human}.txt" => "log-2021-08-20_01-40-11-350800686.txt"

Q: Is it sufficient for your use case if all you can do is choose whether the timestamp suffix is a Unix timestamp or a more human-readable timestamp (like above)? Or is there a need in your use case for more fine-grained control, such as with a templating system?

@riverlee2014
Copy link
Author

This format with human tags can already meet our scene. Thank you!

@jkirschner-hashicorp
Copy link
Contributor

Full templating has more design complexities that we haven't fully worked through yet. An alternative which is perhaps easier would be having a separate config like logPathTimeSuffix=”human”. You wouldn't be able to "template" the name, but you would be able to determine the type of suffix (Unix machine time or human readable).

Would that work for your use case? And is there a benefit to you to have more control than this (such as with a templating option)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/operator-usability Replaces UX. Anything related to making things easier for the practitioner type/enhancement Proposed improvement or new feature type/question Not an "enhancement" or "bug". Please post on discuss.hashicorp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants