i have simple spring boot jar application, uses custom logging library. ( extension on top of log4j2 ). log4j2.xml element configuration has name of "package" appender can found.
this custom logging library works fine other .war,.jar files , other standalone java implementations other spring boot.
as spring boot documentation says, had added log4j2.xml class path , when run on eclipse ide works expected.
however when try build jar using, uber jar finds log4j2.xml fails find custom logging library, though jar in lib folder of packaged jar.
<plugin> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifactid> <version>1.2.4.release</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> i checked sequence of classloading happens between uber jar , eclipse ide, , difference clear uber jar loads core log4j library , starts reading xml before the custom appender loaded. classnotfound exception , no logging.
while eclipse loads in lib folder.
i moved appender code logging jar spring boot project, works. bundling appender jar , referring through pom doesn't work.
also using jarlauncher configuration, should ideally load lib folder.
here closest link got same problem,
http://www.widecodes.com/cjvvwxxgkq/how-to-create-custom-appender-for-log4j2-in-spring.html
but looks developer had appender in workspace rather jar. :-(. works me.
i new springboot, how make logging work? in advance.
well found solution, problem not spring boot, way custom logging api built. built -proc:none compiler argument, dint allow log4j annotations built. log4j2 annotations when built creates log4j2plugin.dat missing.
while log4j2 documentation not elaborate on part much, stackoverflow had users talk .dat file.
once argument removed custom logging component , built, , spring boot project built newly built logging component , spring boot able find appender , load it.
not sure why mvn spring-boot:run let work, ( understandable eclipse did ) not java -jar. custom appender has worked other war/stand alone jar applications , why spring boot alone has have problem it. take it, classloader works different.
Comments
Post a Comment