Open vojkny opened 5 years ago
@knyttl @cstancu FYI, this "Unrecognized format specifier" stuff is Log4j2 encountering a format specifier in the pattern that it does not have a converter for. Log4j2 registers converters (and all other configuration components) through an annotation-based plugin mechanism. This plugin mechanism reads components from META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat
in the jar. The log4j2-core jar has configuration for the Log4j built-in components, apps may contribute custom components by having this file in their own jar. This file is produced by an annotation processor in the log4j-core jar.
The file is in binary format and contains a bunch of stuff for each component, including its fully qualified class name. During log4j2 initialization, it reads this Log4j2Plugins.dat
file and creates a plugin registry.
After that, log4j reads the log4j2.xml
configuration file and looks up elements from that config file in the plugin registry. At this stage, the plugin classes are instantiated, using reflection.
It seems to me that what is needed is a way to generate a reflect-config.json
from the META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat
in the log4j-core
jar and potentially in app jars that have custom Log4j2 components.
The cleanest place to do this is in the Log4j2 annotation processor. I created https://issues.apache.org/jira/browse/LOG4J2-2604 for this.
@knyttl I could be wrong but your reflection-config.json is missing allDeclaredConstructors = true
for the log4j classes, also, are you sure these sections work?
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
(Possibly related with https://github.com/oracle/graal/issues/808)
Within our graal-compiled project we have issue with log4j2. When anything is to be logged, it gets to reflection issues.
https://gitlab.com/GoOutPublic/MicronautKotlinDemo/blob/master/
We have declared reflect-config.json as follows:
https://gitlab.com/GoOutPublic/MicronautKotlinDemo/blob/master/reflect-config.json
The error can be seen in this CI run:
https://gitlab.com/GoOutPublic/MicronautKotlinDemo/-/jobs/204230245