When you launch the application from the IDE, the jar starts without dependency injection and you have no log settings conflicts. But when you convert the application to a fat jar, then all the dependencies will be inserted into your jar project file, and your log4j parameters, which come from external jar files (dependencies), may be conflicting, while the fatJar process combines them into one artifact.
In this case, I think your "Log4j2Plugins.dat" files may be conflicting. Of course, you can open the fatJar file using a zip editor (for example: 7Zip), go to fatJar as shown below, and delete one of the conflicting files (you can choose the smallest one) from your fatJar. Launch fatJar and verify that the log works correctly.
\ META-INF \ org \ Apache \ Logging \ log4j \ kernel \ Config \ Plugins \ Log4j2Plugins.dat
Now we can check the dependencies (artifacts) and find which ones contain the Log4j2Plugins.dat files. That way, you can exclude modules that have a file from your build tool, and then the process for creating fatJar will exclude conflicting files, and your new fatJar file may start logging as expected.
In my case, the fatJar module imports some other modules from Spring Boot, and when I exclude conflicting logging libraries, my fatJar starts to log without any errors.
configurations { all*.exclude module: 'spring-boot' all*.exclude module: 'spring-boot-starter-logging' all*.exclude module: 'logback-classic' all*.exclude module: 'commons-logging' }
Ergin source share