I have a question about the RotationAtTimeStrategy. For instance, I start my application at 11:00, and let it run until 17:00. At this time, I stop it, and it won't run until tomorrow. Then, I restart my application at 10:00, and I have a bad surprise: the log file isn't rotated, the same as yesterday is used !
I'm curious, so I went to find the code responsible for that behavior. Then, I found:
- Code: Select all
Timespan tsp(0, 0, 1, 0, 1000); // 0,00:01:00.001
_threshold += tsp;
while (!(_threshold.minute() == _minute &&
(-1 == _hour || _threshold.hour() == _hour) &&
(-1 == _day || _threshold.dayOfWeek() == _day)));
// round to :00.0 seconds
_threshold.assign(_threshold.year(), _threshold.month(), _threshold.day(), _threshold.hour(), _threshold.minute());
The next rollover is set at "tomorrow",00:00! So it will never rotate my file if I stop my application before!
How can I force the logger to rotate my files every day at midnight or if it is not already done (because the application was off)? Is there another strategy or may I create another strategy class?
Thansk in advance.