Skip to content
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

DefaultRolloverStrategy creating rolled over log files more than the configured limit #3475

Open
vshreens opened this issue Feb 20, 2025 · 3 comments
Labels
waiting-for-user More information is needed from the user

Comments

@vshreens
Copy link

vshreens commented Feb 20, 2025

Hi,

We are using the log4j version 2.24.3 and have an observation where the rolling over of the log files was not in control and rolled over numbering went beyond the configured limit as the logs were getting generated continuously.

Log4j configuration used in application:

Image

Rolled over logs:
$ ls -alhtr test.log*
26M Feb 15 13:02 test.log.33075973
26M Feb 15 13:02 test.log.33075972
26M Feb 15 13:02 test.log.33075971
26M Feb 15 13:02 test.log.33075970
$ ls -alhtr test.log*
26M Feb 15 13:02 test.log.33075979
26M Feb 15 13:02 test.log.33075978
26M Feb 15 13:02 test.log.33075977
26M Feb 15 13:02 test.log.33075976

We wanted to understand if there is any known issue that is causing this or reported already in log4j 2.24.3. Thanks.

@ppkarwasz
Copy link
Contributor

@vshreens,

Can you add your configuration snippet as text, so we can test it?

@ppkarwasz ppkarwasz added waiting-for-user More information is needed from the user and removed waiting-for-maintainer labels Feb 20, 2025
@vshreens
Copy link
Author

vshreens commented Feb 20, 2025

Please find it below: I was unable to paste it properly in text format in the earlier message.

    <RollingFile name="test" fileName="test.log" filePattern="test.log.%i" append="true" immediateFlush="true">
        <PatternLayout>
            <pattern>%d{YYYY-MM-dd'T'HH:mm:ss.SSSSSSXXX}, %level{FATAL=crit, WARN=warning, DEBUG=debug, ERROR=err, INFO=info},  , [%t] [%c:%M:%L] | %m%n</pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="25 MB" />
        </Policies>
        <DefaultRolloverStrategy fileIndex="min" max="4">
            <Delete basePath="LOG_PATH" maxDepth="1">
                <IfFileName glob="test.log.*">
                    <IfAny>
                        <IfAccumulatedFileSize exceeds="300 MB" />
                    </IfAny>
                </IfFileName>
            </Delete>
        </DefaultRolloverStrategy>
    </RollingFile>

@github-actions github-actions bot added waiting-for-maintainer and removed waiting-for-user More information is needed from the user labels Feb 20, 2025
@ppkarwasz
Copy link
Contributor

@vshreens,

Your configuration snippet seems to work correctly. Are you sure you don't have a different RollingFile appender configured to write to test.log, but with different configuration options? Are you restarting your application after a modification to the triggering policies and rollover strategy? Changes to those values are not taken into account during a reconfiguration event, unless you also change the file name.

@ppkarwasz ppkarwasz added waiting-for-user More information is needed from the user and removed waiting-for-maintainer labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-user More information is needed from the user
Projects
None yet
Development

No branches or pull requests

2 participants