-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
RollingPolicy MaxHistory not deleting old files #184
Comments
I have the same issue with simple config
|
I can reproduce the issue with the programmatic config, but not with the XML config. |
@tony19 in which moment logback performs deleting? Can you give me the name of this method? |
The files are automatically deleted at startup (if configured with Line 182 in 45c2dba
|
@tony19 , do you have any thoughts how we can fix the issue with programmatic config? the logic which setup logback placed in another module and used by several apps. i guess i can't just change it to xml |
assets-.zip |
@tony19 I've created a small example illustrated the problem. Check it, please. As you can see on a screenshot maxHistory parameter is 2, but there are 5 log files in the logs directory. |
@tony19 Hello! Have you any news on it? |
@FilenkovMaxim I was able to reproduce the problem with logs not being deleted when the timestamp is using a daily rollover ( |
@tony19 I don't think that is related problems. I checked RollingPolicy in this example without run resetLogs() method. |
The daily rollover pattern is indeed related, as it's one way I can reproduce the problem of missed deletions. The rollover seems to work fine when using a second-based rollover pattern ( I have a simpler method of reproducing the issue. Add |
Here's what's happening: When a filename pattern contains two date patterns like this: <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_DIR}/app.%d{yyyyMMdd}_%d{HHmmss,UTC}.log</fileNamePattern> ...the second date pattern (
...but the log files are actually named with nonzero times for the second timestamp like this:
|
@tony19 Thanks for finding the source of the issue, do you think you can fix it in the next few days? |
Fixed in v_1.3.0-3 |
@AlexandrSalin I've verified the fix with your config in my test app. Note that the solution implemented for LOGBACK-162 did not actually fix the problem in full, and had critical holes that would allow archive removals to be missed. I've refactored it in logback-android. |
@FilenkovMaxim Note your filename pattern contains multiple date specifiers, which prevents logback from finding the correct files to remove:
Only one date specifier can be the "primary" one. The auxiliary ones must be marked with
|
@tony19 thank you for explanation, I've changed my config already. |
I'm working on the release right now. You can download it manually in the meantime for local testing. I also forgot to mention that when using multiple date specifiers, they all should have the same timezone. logback would still work, but it could be confusing for users to see two different timestamps in the filename. It should look like this:
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
seems like it already fixed in
https://jira.qos.ch/browse/LOGBACK-162
but doesn't work for android
my config
The text was updated successfully, but these errors were encountered: