Reputation: 103
i am trying to generate logs in Json format for that using log4j2 JsonTemplateLayout with LogstashJsonEventLayoutV1.json as the template. When i run the code using intellij everything works as expected. But using java -jar command it fails with Unable to locate plugin for type JsonTemplateLayout
Below are the logs from intellij and command line using java -jar
Logs using java -jar command 2021-04-20 19:02:55,123 main DEBUG null null initializing configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration@6f45df59
2021-04-20 19:02:55,140 main DEBUG Installed 1 script engine Warning: Nashorn engine is planned to be removed from a future JDK release 2021-04-20 19:02:55,723 main DEBUG Oracle Nashorn version: 11.0.10, language: ECMAScript, threading: Not Thread Safe, compile: true, names: [nashorn, Na shorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], factory class: jdk.nashorn.api.scripting.NashornScriptEngineFactory 2021-04-20 19:02:55,723 main DEBUG PluginManager 'Core' found 122 plugins 2021-04-20 19:02:55,723 main DEBUG PluginManager 'Level' found 0 plugins 2021-04-20 19:02:55,739 main ERROR Unable to locate plugin type for JsonTemplateLayout
Logs when executing from Intellij 2021-04-20 18:52:50,289 main DEBUG Apache Log4j Core 2.14.1 initializing configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration@6ff29830 2021-04-20 18:52:50,306 main DEBUG Installed 1 script engine Warning: Nashorn engine is planned to be removed from a future JDK release 2021-04-20 18:52:51,122 main DEBUG Oracle Nashorn version: 11.0.10, language: ECMAScript, threading: Not Thread Safe, compile: true, names: [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], factory class: jdk.nashorn.api.scripting.NashornScriptEngineFactory 2021-04-20 18:52:51,124 main DEBUG PluginManager 'Core' found 124 plugins 2021-04-20 18:52:51,124 main DEBUG PluginManager 'Level' found 0 plugins 2021-04-20 18:52:51,137 main DEBUG Building Plugin[name=property, class=org.apache.logging.log4j.core.config.Property].
Can anyone please help me resolve this issue? Many thanks
Upvotes: 5
Views: 3080
Reputation: 103
below link helped to resolve this issue
https://github.com/edwgiz/maven-shaded-log4j-transformer
Upvotes: 3