natefinch / lumberjack

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

Add ability to have MaxBackups zero to rotate a single file. #30

Closed yonderblue closed 7 years ago

natefinch commented 7 years ago

Do you mean that you'd like max backups zero and maxsize 100MB to simply delete the file and create a new one when it gets above 100MB? Can you explain why you'd want to do that? When the file rotated, you'd lose all your log information, so if anything goes wrong soon after rotation, you'd have no idea what was going on.

A better option is to make the max size half as much (in this example, 50MB), and have max backups 1. Then you'd still be limited to using 100MB of disk space for logs, but you'd never be in a situation where you have no log history.

yonderblue commented 7 years ago

I meant rolling over one file, like taking the last half of the contents and over writing the first half, and putting the new data at the last half.

yonderblue commented 7 years ago

And without a time suffix

natefinch commented 7 years ago

I guess I don't know why you wouldn't just have maxbackups be 1 and make maxsize 50. The main problem is that this would be a breaking change for people that already use maxbackups=0 and just use maxage to delete old log files. We'd need some sort of new value to indicate that you want to rotate internally to a single file, and I don't really see that this really fixes any problem with the package as it is. It's also a significant difference from how everything else in the package works (and how most every other rotation scheme works, to my knowledge).

yonderblue commented 7 years ago

Main reason is so that the file is stably named so other things can refer to it without it changing or getting removed and recreated.

natefinch commented 7 years ago

I don't think this is doable in the current system.