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

add date for ouput filename #229

Closed
xleng2019 opened this issue Jul 27, 2022 · 3 comments · Fixed by #235
Closed

add date for ouput filename #229

xleng2019 opened this issue Jul 27, 2022 · 3 comments · Fixed by #235

Comments

@xleng2019
Copy link

I tried to add "output = file:/var/log/snoopy_$(date +%Y-%m-%d) " in the config file in order to add date to the name of log file. However, it didn't work. Am I doing it the wrong way? Thx

@bostjan
Copy link
Member

bostjan commented Jul 27, 2022

Hey @xleng2019, no, you're not doing it wrong - it is just (currently) not supported.

Question: why are you trying to implement the log rotation with Snoopy itself? Why not just use existing tools (i.e. logrotate) that already rotate other logs on your system? Just curious, and describing actual real word use cases usually helps with decisions what to implement in the future.

PS: Technically, to work around this right now, you could run a socat UNIX-RECV:/var/run/snoopy.sock STDOUT | chronolog /var/log/snoopy_%Y-%m-%d in the background, and use output = socket:/var/run/snoopy.sock in your snoopy.ini to achieve the desired result. A bit convoluted approach, but it should work.

PPS: Where did you get the idea to try the $(...) syntax from? It's not used anywhere within Snoopy right now. I would kinda understand you trying to use the %{...} syntax, since that is used in the message_format setting already (and in the syslog_ident setting in the upcoming version), but $(...) is definitely nowhere to be seen. :)

PPPS: Shouldn't be too hard to implement, though, and it's an interesting suggestion. Thanks.

@xleng2019
Copy link
Author

I've known that. I'm going to use logrotate. Thanks.

@bostjan bostjan closed this as completed Jul 29, 2022
bostjan added a commit to bostjan/snoopy that referenced this issue Aug 4, 2022
…y.log-%{datetime:%Y-%m-%d}`)

(Fixes GitHub issue a2o#229.)
@bostjan bostjan linked a pull request Aug 4, 2022 that will close this issue
bostjan added a commit to bostjan/snoopy that referenced this issue Aug 4, 2022
…y.log-%{datetime:%Y-%m-%d}`)

(Fixes GitHub issue a2o#229.)
@bostjan bostjan added this to the 2.5.0 milestone Aug 4, 2022
@bostjan
Copy link
Member

bostjan commented Aug 4, 2022

Hey @xleng2019, you're in luck - some unrelated refactoring made implementing this feature very easy ;)

It is currently already available in master, and it will be released with Snoopy v2.5.0 soon. Enjoy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants