-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing codewaiting-for-maintainer
Milestone
Description
Description
Per documentation I should be able to create a custom ContextDataProvider. However, when following the documented steps, the context is not resolved. This is also reported here.
I created a minimal reproducible example where I followed the steps described in the docs:
- Custom implementations should implement the
org.apache.logging.log4j.core.util.ContextDataProviderinterface (MyContextDataProvider) - 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)
I created a unit test with a log4j2-test.properties setup 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
Metadata
Metadata
Assignees
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing codewaiting-for-maintainer