when log4j2.xml has custom plugin config in vertx root-fat.jar, log4j2 do not work

93 views
Skip to first unread message

Jim

unread,
Jun 26, 2018, 10:00:24 PM6/26/18
to vert.x
I write one vertx project and use log4j2 as my log framework.
and I use custom log4j2 plugin to configure my custom property in log4j2.xml
it run ok when I run the project in idea, but failed when I package the code into root-fat.jar.
Thanks.

the dependency:
<project.log4j2.version>2.11.0</project.log4j2.version>
<project.slf4j.version>1.7.2</project.slf4j.version>
<project.logback-classic.version>1.1.5</project.logback-classic.version>
<project.vertx.version>3.5.1</project.vertx.version>

xml config file:

and the plugin code:


use log4j2 in vertx and all-asynchronzied feature

the maven build plugin


the command in terminal


and the fail message


con...@liveraise.com

unread,
Jul 9, 2018, 4:12:29 PM7/9/18
to vert.x
I recall having a log4j2 issue with fatjar, the solution for us was to add these excludes to the fatjar:
        exclude "META-INF/org/apache/logging/log4j/core/config/plugins/*.dat"
        exclude 'META-INF/log4j-provider.properties'

Jim

unread,
Jul 31, 2018, 9:12:59 PM7/31/18
to vert.x
I try it and it works!
Thanks!

在 2018年7月10日星期二 UTC+8上午4:12:29,con...@liveraise.com写道:

Steve Hummingbird

unread,
Aug 2, 2018, 1:29:05 PM8/2/18
to vert.x
I don't recall having seen this with a fresh vertx project without any additional dependencies. However, in case you include dependencies that include additional *.dat files, you might be running into this issue: https://issues.apache.org/jira/browse/LOG4J2-954 The printed error message does not make it very easy to link to the actual issue.

I was hitting that issue when I included the rollbar dependency. There is a gradle or a maven plugin which you can use to concatenate the *.dat files, which resolved the issue in my case.
Reply all
Reply to author
Forward
0 new messages