Skip to content

Fix createOnDemand for Rolling File Appender#4072

Open
ramanathan1504 wants to merge 4 commits intoapache:2.xfrom
ramanathan1504:issue-2006
Open

Fix createOnDemand for Rolling File Appender#4072
ramanathan1504 wants to merge 4 commits intoapache:2.xfrom
ramanathan1504:issue-2006

Conversation

@ramanathan1504
Copy link
Copy Markdown
Contributor

@ramanathan1504 ramanathan1504 commented Mar 20, 2026

Fixes #2006

PR Notes: RollingFile createOnDemand validation

Scope

  • Module tested: spring-boot-test only
  • core-java-test and log4j2-web-test left unchanged

What was run

  • Local dependency check confirmed 2.26.0-SNAPSHOT artifacts resolved from ~/.m2
  • Startup timing probes from SpringBootTestApp#printLogPathState used as source of truth

Results (2.26.0-SNAPSHOT)

createOnDemand="true" (default log4j2.xml)

  • main-entry: dir=false app.log=false app-json.log=false
  • after LogManager.getLogger: dir=false app.log=false app-json.log=false
  • after first log event: dir=true app.log=true app-json.log=true

Conclusion: directory and files are created on first log event (expected on-demand behavior).

createOnDemand="false" (log4j2-createOnDemand-false.xml)

  • main-entry: dir=false app.log=false app-json.log=false
  • after LogManager.getLogger: dir=true app.log=true app-json.log=true
  • after first log event: dir=true app.log=true app-json.log=true

Conclusion: eager creation occurs before first log event (expected non-demand behavior).

@ramanathan1504 ramanathan1504 changed the title [LOG4J2-issue-2006] RollingFile createOnDemand validation [LOG4J2-2006] RollingFile createOnDemand validation Mar 20, 2026
@vy vy changed the title [LOG4J2-2006] RollingFile createOnDemand validation Fix createOnDemand for Rolling File Appender Apr 23, 2026
Copy link
Copy Markdown
Member

@vy vy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked with @ppkarwasz, the fix looks good. Could you also add a changelog entry (referencing to both the Issue and PR IDs), please?

@github-project-automation github-project-automation Bot moved this to Changes requested in Log4j pull request tracker Apr 23, 2026
@vy
Copy link
Copy Markdown
Member

vy commented Apr 23, 2026

@ramanathan1504, if you can get this merged until next week, I can ship it with 2.26.0.

@ramanathan1504
Copy link
Copy Markdown
Contributor Author

@ramanathan1504, if you can get this merged until next week, I can ship it with 2.26.0.
@vy within a day i will complete👍

@vy
Copy link
Copy Markdown
Member

vy commented Apr 24, 2026

@ramanathan1504, please do NOT force-push. It truncates the entire conversation history and I cannot see what incremental changes you've pushed. That is, I need to re-review everything from scratch.

Comment thread src/changelog/2.6/LOG4J2-2006_Fix_RollingFileAppender_createOnDemand.xml Outdated
@ramanathan1504
Copy link
Copy Markdown
Contributor Author

@ramanathan1504, please do NOT force-push. It truncates the entire conversation history and I cannot see what incremental changes you've pushed. That is, I need to re-review everything from scratch.

@vy Thanks for the clarification. I will avoid force-pushing and will push incremental commits.

…tion until the first log event change log moving from 2.6 to 2.x
@ramanathan1504 ramanathan1504 requested a review from vy April 24, 2026 07:59
@github-project-automation github-project-automation Bot moved this from Changes requested to Approved in Log4j pull request tracker Apr 24, 2026
@vy vy enabled auto-merge (squash) April 24, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

RollingFileAppender with createOnDemand="true" eagerly tries creating directories

2 participants