lukasalexanderweber opened a new issue, #2331: URL: https://github.com/apache/logging-log4j2/issues/2331
## Description Per documentation I should be able to create a [custom ContextDataProvider](https://logging.apache.org/log4j/2.x/manual/extending.html#ContextDataProvider). However, when following the documented steps, the context is not resolved. This is also reported [here](https://stackoverflow.com/questions/77455596/define-contextdataprovider-in-log4j2-at-creation-time-of-logger). I created a [minimal reproducible example](https://github.com/lukasalexanderweber/ContextDataProviderMRE/) where I followed the steps described in the docs: 1. Custom implementations should implement the org.apache.logging.log4j.core.util.ContextDataProvider interface ([MyContextDataProvider](https://github.com/lukasalexanderweber/ContextDataProviderMRE/blob/main/src/main/java/custom/context/data/provider/MyContextDataProvider.java)) 2. and declare it as a service by defining the implementation class in a file named META-INF/services/org.apache.logging.log4j.core.util.ContextDataProvider ([org.apache.logging.log4j.core.util.ContextDataProvider](https://github.com/lukasalexanderweber/ContextDataProviderMRE/blob/main/src/main/resources/META-INF/services/org.apache.logging.log4j.core.util.ContextDataProvider)) I created a [unit test](https://github.com/lukasalexanderweber/ContextDataProviderMRE/blob/main/src/test/java/custom/context/data/provider/MyContextDataProviderTest.java) with a [log4j2-test.properties setup](https://github.com/lukasalexanderweber/ContextDataProviderMRE/blob/main/src/test/resources/log4j2-test.properties) and expect for the path `src/test/logs/${ctx:tenant}` that the tenant is resolved by `MyContextDataProvider`. However, an error is printed that the file with the unresolved tenant cannot be created. It works as expected when the tenant is set via `ThreadContext.put("tenant", "tenant1");` ## Configuration **Version:** 2.23.0 **Operating system:** Windows 10 **JDK:** Corretto-17.0.8.8.1 ## Logs ``` 2024-03-01T08:40:19.499742800Z main ERROR Unable to create file src/test/logs/${ctx:tenant}/logs.log java.io.IOException: Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch at java.base/java.io.WinNTFileSystem.canonicalize0(Native Method) at java.base/java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:462) at java.base/java.io.File.getCanonicalPath(File.java:626) at java.base/java.io.File.getCanonicalFile(File.java:651) at org.apache.logging.log4j.core.util.FileUtils.makeParentDirs(FileUtils.java:141) at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:863) ``` ## Reproduction see [ContextDataProviderMRE](https://github.com/lukasalexanderweber/ContextDataProviderMRE) -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
