-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Adding rollingFile #14
Conversation
@liran2000, I have spent quite some time thinking on this issue. I want to share some thoughts your request has triggered and the tentative plan I have in mind.
try (RotatingFileOutputStream stream = new RotatingFileOutputStream(config)) {
// Do great stuff with the "stream"!
}
RotationConfig.getDefaultExecutorService().shutdown(); Hence, I want to come up with an API that users can ensure an ultimate completion: RotationConfig config = RotationConfig
.builder()
.file("/tmp/app.log")
.filePattern("/tmp/app-%d{yyyyMMdd-HHmmss.SSS}.log")
.policy(DailyRotationPolicy.instance())
.build();
try (RotationContext context = RotationContext
.builder()
.clock(clock) // (optional)
.executor(executor) // for background tasks, e.g., compression (optional)
.scheduler(scheduler) // for time-sensitive background tasks, e.g., rotation, rolling (optional)
.build();
RotatingFileOutputStream stream = new RotatingFileOutputStream(config, context)) {
// Do great stuff with the "stream"!
} // Will block until all streams and executors/schedulers are closed! All the aforementioned changes will be backward incompatible, hence I am targeting a |
Basic idea is to keep it simple, and similar to common logging frameworks.
Thank you for your outputs, you can share your thoughts on my comments. |
974e611
to
68a53c1
Compare
@liran2000, I have pushed a modified version of your work to Rather than creating a I have another question: I doubt if rolling can work in combination with compression. Because when compression is enabled, there will be a background task renaming |
@vy looks good. Some comments:
Thanks |
Thanks so much for assisting me in this story @liran2000! I will improve the docs a bit more, publish a release, and close this story. |
8c554e4
to
e098109
Compare
|
Enhancement of rolling file by rollingFile configuration option.
Rolling file by indexes, based on SizeBasedRotationPolicy, similar to log4j RollingFileAppender (defaults to
false
).Algorithm Implementation is taken and edited to fit from log4j RollingFileAppender.
Backward compatible:
All unit tests are passing. Existing options and implementations remain untouched.
rollingFile enhancement is fully covered in a new unit test, which prints more than the max data, then validates that all backup indexes files exists, and do a sample test on the byte content of the files.