Details
-
Sub-task
-
Resolution: Fixed
-
Major
-
1.1.8
-
None
-
Ubuntu
Description
I did some testing recently by porting fix of LOGBACK-1166 to our project which needs this fix urgently.
It seems this fix still cannot fix totalSizeCap issue entirely. It cannot cover below case:
1. If we are using release 1.1.7 and it already got lots of logs (size is more than 2^31 -1 ~= 2G), It doesn't work if I hope that this fix can help to clean the old logs through upgrading.
2. If we configure totalSizeCap more than 2^31 -1 ~= 2G, it seems it will get overflow when we go through the file length. (I didn't test this one, it seems it is an issue with my understanding).
After checked the code, it seems we need to change the local variable (totalSize and totalRemoved)'s type from int to long in function void capTotalSize(Date now) in file logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TimeBasedArchiveRemover.java.
void capTotalSize(Date now) { int totalSize = 0; int totalRemoved = 0; for (int offset = 0; offset < maxHistory; offset++) { Date date = rc.getEndOfNextNthPeriod(now, -offset); File[] matchingFileArray = getFilesInPeriod(date); descendingSortByLastModified(matchingFileArray); for (File f : matchingFileArray) { long size = f.length(); if (totalSize + size > totalSizeCap) { addInfo("Deleting [" + f + "]" + " of size " + new FileSize(size)); totalRemoved += size; f.delete(); } totalSize += size; } } addInfo("Removed " + new FileSize(totalRemoved) + " of files"); }
Attachments
Issue Links
- is duplicated by
-
LOGBACK-1277 Capping log files does not work with large log file base
- Resolved
-
LOGBACK-1295 SizeAndTimeBasedRollingPolicy doesnt work with the totalSizeCap limit on the same day
- Resolved