ppkarwasz commented on PR #3225: URL: https://github.com/apache/logging-log4j2/pull/3225#issuecomment-2489033877
@AlbaHerrerias, The problem with `surefire-junit-platform` was that either Surefire or JUnit 5 (I don't remember which one) initializes JUL (and therefore Log4j) way before control is transferred to the test class. Therefore this code executes too late: https://github.com/apache/logging-log4j2/blob/031d4dab8b32e1d3802f73495a7bb36b8b2685f5/log4j-jul/src/test/java/org/apache/logging/log4j/jul/test/CoreLoggerTest.java#L59-L62 To workaround that, all the tests must be split into at least 4 Surefire runs, depending on the system properties that they need. Most test classes require the `java.util.logging.manager` property to be set (except `Log4jBridgeHandlerTest`), but some need additional properties. For example `AsyncLoggerThreadsTest` additionally needs the `log4j2.contextSelector` property to be set: ```xml <execution> <id>async-logger-test</id> <goals> <goal>test</goal> </goals> <phase>test</phase> <configuration> <includes> <include>**/AsyncLoggerThreadsTest.class</include> </includes> <!-- Use custom `j.u.l.LogManager` and an asynchronous selector --> <systemPropertyVariables> <java.util.logging.manager>org.apache.logging.jul.tolog4j.LogManager</java.util.logging.manager> <log4j2.contextSelector>org.apache.logging.log4j.core.async.AsyncLoggerContextSelector</log4j2.contextSelector> </systemPropertyVariables> </configuration> </execution> ``` `CoreLoggerTest` needs an additional `log4j2.julLoggerAdapter` system property. -- 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-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org