You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "snicoll (via GitHub)" <gi...@apache.org> on 2025/12/12 15:44:49 UTC
[I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
snicoll opened a new issue, #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001
## Description
Apologizes for the lack of details but @ppkarwasz mentioned it could reproduce the problem on their end.
I am configuring a `SizeBasedTriggeringPolicy` on a Spring Boot application and rolling fails as follows:
```
2025-12-12T14:23:34.834545Z scheduling-1 ERROR An exception occurred processing Appender File
java.lang.IndexOutOfBoundsException: No group 1
at java.base/java.util.regex.Matcher.checkGroup(Matcher.java:1845)
at java.base/java.util.regex.Matcher.group(Matcher.java:686)
at org.apache.logging.log4j.core.appender.rolling.AbstractRolloverStrategy.getEligibleFiles(AbstractRolloverStrategy.java:144)
at org.apache.logging.log4j.core.appender.rolling.AbstractRolloverStrategy.getEligibleFiles(AbstractRolloverStrategy.java:93)
at org.apache.logging.log4j.core.appender.rolling.AbstractRolloverStrategy.getEligibleFiles(AbstractRolloverStrategy.java:85)
at org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy.purgeAscending(DefaultRolloverStrategy.java:447)
at org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy.purge(DefaultRolloverStrategy.java:431)
at org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy.rollover(DefaultRolloverStrategy.java:571)
at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:619)
at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:507)
at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.checkRollover(RollingFileManager.java:418)
at org.apache.logging.log4j.core.appender.RollingFileAppender.append(RollingFileAppender.java:336)
at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:160)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:133)
at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:124)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:88)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:711)
at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:669)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:645)
at org.apache.logging.log4j.core.config.LoggerConfig.logParent(LoggerConfig.java:702)
at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:671)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:645)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:589)
at org.apache.logging.log4j.core.config.DefaultReliabilityStrategy.log(DefaultReliabilityStrategy.java:73)
at org.apache.logging.log4j.core.Logger.log(Logger.java:187)
at org.apache.logging.log4j.spi.AbstractLogger.tryLogMessage(AbstractLogger.java:2970)
at org.apache.logging.log4j.spi.AbstractLogger.logMessageTrackRecursion(AbstractLogger.java:2922)
at org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2904)
at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2653)
at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:2393)
at org.apache.logging.slf4j.Log4jLogger.debug(Log4jLogger.java:113)
```
When this happens logs to file stop.
## Configuration
Log4J 2.25.2, MacOS, JDK 25
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "snicoll (via GitHub)" <gi...@apache.org>.
snicoll commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3659398027
@vy I think I am confused.
With `2.24.3`, a `filePattern` of `${sys:LOG_FILE}.%d{yyyy-MM-dd}.%i.gz` generates the expected format. With `2.25.2` it generates something like `myapp.log.test.2025-12-16.%i.61025CET`. How can it be a documentation fix? What's wrong with this pattern and why does it work with Log4j 2.24?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3647258802
The problem occurs if `filePattern` contains something that matches `.*%(?<ZEROPAD>0)?(?<PADDING>\d+)?i.*`, but it doesn't actually contain any valid `%i` pattern.
Patterns such as `%%i` match the regex without being a true `%i`, which causes the method to fail.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "snicoll (via GitHub)" <gi...@apache.org>.
snicoll commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3660874216
> Could you provide a complete configuration file and possibly a reproducer?
Unfortunately this only happens with the code in the PR you and I are working on. I've tried to reproduce on `main` with `2.25.2` and I couldn't. The PR is actually providing support for rolling policy so it might miss something important, I have no idea. If you're ok to build from source, you can reproduce by cloning [snicoll@pr/47260](https://github.com/snicoll/spring-boot/tree/pr/47260) and running [this main method](https://github.com/snicoll/spring-boot/blob/ab9833bc5cfb7b3cafa628f90eb92622ff53f9e9/smoke-test/spring-boot-smoke-test-log4j2/src/main/java/smoketest/log4j2/SampleLog4j2Application.java#L40). You need to wait a bit for the main log file to hit `100KB`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "snicoll (via GitHub)" <gi...@apache.org>.
snicoll commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3799760212
@ppkarwasz happy new year! Wondering if you had the time to look at the above or if, alternatively, you can give me some pointers for me to look at. Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "snicoll (via GitHub)" <gi...@apache.org>.
snicoll commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3985115810
Thanks @ppkarwasz, I did that and merged the PR on the SB side. I suppose the plan is to change that again once this issue is fixed?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3803863301
@snicoll,
I won't be able to look at it before next week, since I am heading to FOSDEM.
The problem must be caused by an unconventional `filePattern` argument, but I am not able to figure out which, without debugging.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy closed issue #4001: SizeRollingPolicy fails to retrieve eligible files
URL: https://github.com/apache/logging-log4j2/issues/4001
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "snicoll (via GitHub)" <gi...@apache.org>.
snicoll commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3945722392
@ppkarwasz I could use some help to know where to debug the faulty file pattern.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3660444258
Hi @snicoll,
Could you provide a complete configuration file and possibly a reproducer? The issue appears to be some sort of concurrency/reentrancy issue in the date formatter: `2025-12-16.%i.61025CET` seems like a partially overwritten version of a timestamp.
We had such an issue in #3792, but we fixed it in version `2.25.1`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3664415164
I'll try that, thanks!
Not sure, when I'll have the time, but spring-projects/spring-boot#47260 can only be included in Spring Boot `4.1.0`, right? By that time I'll certainly figure out what is going on and we'll probably have a `2.26.0` release too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3951006227
Hi @snicoll,
Sorry for the delay: busy times at my day job.
The issue appears to be caused by the `filePattern` used in spring-projects/spring-boot#47260:
```xml
<RollingFile name="File" fileName="${sys:LOG_FILE}"
filePattern="${sys:LOG4J2_ROLLINGPOLICY_FILE_NAME_PATTERN:-${sys:LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}">
```
After substitution, this effectively becomes:
```
myapp.log.%d{yyyy-MM-dd.%i.gz}
```
This string matches the regex used to detect `%i` (`.*%(?<ZEROPAD>0)?(?<PADDING>\d+)?i.*`), but it does **not** actually contain a real `%i` rollover token: the `%i` is inside the date format. That mismatch triggers the failure described in this issue.
### Expansion logic
This happens because `StrSubstitutor` does not support escaping `}` (see apache/logging-log4j2#2679). Although it supports nested `${...}` expressions, it treats the `}` in `%d{yyyy-MM-dd}` as the closing brace of the outer substitution.
As a result, the default value is prematurely terminated and effectively parsed as:
```
${sys:LOG_FILE}.%d{yyyy-MM-dd
```
which expands to:
```
myapp.log.%d{yyyy-MM-dd
```
The remaining `.%i.gz}` is then treated as a **literal** suffix and appended unchanged.
### Workaround
Instead of using the `:-` default syntax, define the default via a dedicated property:
```xml
<Properties>
<Property name="LOG4J2_ROLLINGPOLICY_FILE_NAME_PATTERN"
value="${sys:LOG_FILE}.%d{yyyy-MM-dd}.%i.gz"/>
</Properties>
<Appenders>
<RollingFile name="File"
fileName="${sys:LOG_FILE}"
filePattern="${sys:LOG4J2_ROLLINGPOLICY_FILE_NAME_PATTERN}">
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3986052452
> I suppose the plan is to change that again once this issue is fixed?
There is no need to change anything after this issue is fixed. Whether you use `${sys:VARIABLE:-<default_value>}` or you define a property named `VARIABLE` with the default value is equivalent and personally I find the latter easier to read.
If you prefer to change it back, you should rather follow #2679. After that issue is solved, you can revert to using:
```
${sys:LOG4J2_ROLLINGPOLICY_FILE_NAME_PATTERN:-${sys:LOG_FILE}.%d{yyyy-MM-dd$}.%i.gz}
```
with `$}` used to escape the closing brace.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3654519499
I suggest either documenting, or _"fixing"_ this. What _"the fix"_ will be, is still an open question.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "snicoll (via GitHub)" <gi...@apache.org>.
snicoll commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3824481538
Got you, enjoy FOSDEM and Brussels! I was hoping to get some pointers to understand why it works without the Boot's PR we are working on.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SizeRollingPolicy fails to retrieve eligible files [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on issue #4001:
URL: https://github.com/apache/logging-log4j2/issues/4001#issuecomment-3692768589
@ppkarwasz, I see that this is related with your and @snicoll's work in spring-projects/spring-boot#47260. I took the liberty of assigning this task to you — I can help with the reviews. Let me know if you disagree.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org