lumberjack icon indicating copy to clipboard operation
lumberjack copied to clipboard

Added ArchiveDir

Open gjrtimmer opened this issue 8 years ago • 3 comments

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:

  • server.log
  • audit.log
  • request.log

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

gjrtimmer avatar Mar 24 '17 18:03 gjrtimmer

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.

natefinch avatar Apr 06 '17 16:04 natefinch

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.

gjrtimmer avatar Apr 06 '17 17:04 gjrtimmer

It's useful, please merge it, thanks!

@natefinch

ghost avatar Jul 21 '18 11:07 ghost