You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ramanathan1504 (via GitHub)" <gi...@apache.org> on 2026/03/20 08:32:19 UTC
[PR] [LOG4J2-issue-2006] RollingFile createOnDemand validation [logging-log4j2]
ramanathan1504 opened a new pull request, #4072:
URL: https://github.com/apache/logging-log4j2/pull/4072
# 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).
--
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: [PR] Fix `createOnDemand` for Rolling File Appender [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy merged PR #4072:
URL: https://github.com/apache/logging-log4j2/pull/4072
--
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: [PR] Fix `createOnDemand` for Rolling File Appender [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 commented on PR #4072:
URL: https://github.com/apache/logging-log4j2/pull/4072#issuecomment-4311519835
> @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.
--
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: [PR] Fix `createOnDemand` for Rolling File Appender [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on PR #4072:
URL: https://github.com/apache/logging-log4j2/pull/4072#issuecomment-4303075893
@ramanathan1504, if you can get this merged until next week, I can ship it with `2.26.0`.
--
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: [PR] Fix `createOnDemand` for Rolling File Appender [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on code in PR #4072:
URL: https://github.com/apache/logging-log4j2/pull/4072#discussion_r3136182449
##########
src/changelog/2.6/LOG4J2-2006_Fix_RollingFileAppender_createOnDemand.xml:
##########
Review Comment:
Move this file to `.2.x.x` directory.
--
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: [PR] Fix `createOnDemand` for Rolling File Appender [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on code in PR #4072:
URL: https://github.com/apache/logging-log4j2/pull/4072#discussion_r3136180580
##########
src/changelog/2.6/LOG4J2-2006_Fix_RollingFileAppender_createOnDemand.xml:
##########
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+ type="fixed">
+ <issue id="2006" link="https://github.com/apache/logging-log4j2/issues/2006"/>
+ <issue id="4072" link="https://github.com/apache/logging-log4j2/pull/4072"/>
+ <description format="asciidoc">
+ Fix RollingFileAppender createOnDemand behavior to correctly defer file and directory creation
Review Comment:
```suggestion
Fix the `createOnDemand` behavior of `RollingFileAppender` to correctly defer file and directory creation
```
--
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: [PR] Fix `createOnDemand` for Rolling File Appender [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on PR #4072:
URL: https://github.com/apache/logging-log4j2/pull/4072#issuecomment-4311467218
@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.
--
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: [PR] Fix `createOnDemand` for Rolling File Appender [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on code in PR #4072:
URL: https://github.com/apache/logging-log4j2/pull/4072#discussion_r3129561970
##########
log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingFileManagerCreateOnDemandTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.rolling;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.nio.file.Files;
+import org.apache.logging.log4j.core.config.NullConfiguration;
+import org.apache.logging.log4j.core.layout.PatternLayout;
+import org.junit.jupiter.api.Test;
+
+class RollingFileManagerCreateOnDemandTest {
+ @Test
+ void testCreateOnDemandDoesNotCreateDirectoryOrFile() throws Exception {
+ String logDir = "target/test-logs/onDemand";
+ String logFile = logDir + "/test.log";
Review Comment:
Would you mind using JUnit's `@TempDir` instead of hardcoding the paths, please?
--
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: [PR] Fix `createOnDemand` for Rolling File Appender [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 commented on PR #4072:
URL: https://github.com/apache/logging-log4j2/pull/4072#issuecomment-4303338577
> @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👍
--
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: [PR] Fix `createOnDemand` for Rolling File Appender [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 commented on code in PR #4072:
URL: https://github.com/apache/logging-log4j2/pull/4072#discussion_r3136266990
##########
src/changelog/.2.x.x/LOG4J2-2006_Fix_RollingFileAppender_createOnDemand.xml:
##########
Review Comment:
Moved from 2.26 to 2.x
--
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