natefinch / lumberjack

lumberjack is a log rolling package for Go
MIT License
4.8k stars 591 forks source link

Added ArchiveDir #39

Open gjrtimmer opened 7 years ago

gjrtimmer commented 7 years ago

Added a new property 'ArchiveDir' Also added description to README.

Explanation and Reason:

Real World Use Case

I have several golang application running; Lumberjack provides nice log rotation, however the log directory gets cluttered, because lumberjack writes to the same directory as the active log file.

So picture this: A logs directory with the following active logs:

Currently Lumberjack will writes all old log files to the same directory as the active logfile. With production systems where you are legally required to save logging for quite some time, this log directory gets quite crowded.

END USE CASE

The provided pull request is very small in code and allows to set a alternate archive directory; but the impact of having the old rotated logs to a separate archive directory is in my opinion very valuable for production systems.

This pull request allows you to organize the location of the old logs.

Also this property was set as non-invasive with full backwards compliancy by setting it to 'omitempty'.

@natefinch Please consider this PR for production system daily operations.

Fully tested; see screenshots lumberjack1 lumberjack2

natefinch commented 7 years ago

Most log rotation mechanisms simply write backup logs to the same directory, AFAIK. I'm trying to avoid feature bloat, and this seems like feature bloat, since there's a semi-reasonable work around. If you have too many logs in the same directory, maybe you should just put them in different directories? I know that then when you want to look at multiple of them on disk you have to skip from directory to directory... but I really don't want this to become a swiss army knife package.

gjrtimmer commented 7 years ago

I understand your point of view about feature bloat. So would it be acceptable to you to either accept this one to the user can have some control or expose some internals of lumberjack so the user can achieve something similar to my feature request.

One final argument for my ArchiveDir against your point of writing to multiple sub directories is to comply to the default linux log file system setup.

I hope you can either accept this or add some expose to give the user the control.

Please don't take any of this personal.

ghost commented 6 years ago

It's useful, please merge it, thanks!

@natefinch