katzgrau/KLogger

Option for current log to be named differently than historical logs

Closed this issue · 4 comments

It would be useful if the current day's logs could be written to a specifically titled file (such as current.log). As the date changes, that file should be renamed to the configured date format. This would make it far easier to monitor the current logs using external utilities.

Thoughts?

I am curious for your use case though? I mean most external utilities should be able to work either way and I fail to see why current.log would make any difference?

Can you explain a bit more? :)

From a purely practical perspective, it makes it visually obvious where the most recent logs are located.

My actual use case is with a development/deployment tool called Nanobox. They have a log monitoring feature that aggregates your app's logs (perhaps from multiple instances) to a centralized dashboard (with alert features sprinkled in). Their feature cannot monitor a directory, but a single log file. Here is the page from their docs.

Not to pass the buck here, but couldn't this be better achieved with a one-line cron job?

cp current.log log_$(date +%F).log && cat /dev/null > current.log

Doing it from within the class would involve constant checking of the filesystem - on every instantiation of the class - which seems a bit silly since it's only something that needs to happen once a day.

@katzgrau This is what I've ultimately done. I just wanted to throw it out there and get your thoughts. I appreciate your feedback!