Log4j2 configuration not found when running standalone application built by shade plugin

前端 未结 4 2139
旧时难觅i
旧时难觅i 2020-12-09 02:31

I have application which when I run from maven log4j2 it is working:

mvn exec:java -Dexec.args=...

but when I run jar as standalone applica

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 02:33

    ok I found this issue about this problem.

    In short, the problem arises when application classes are packaged in uber jar using maven shade plugin. While for log4j2 version 2.8.1 the fix is still pending, the suggested workaround is to update maven pom.xml with extra configuration settings for shade plugin as follow:

        
    
            . . . . .
    
            
                . . . . . 
                
                    . . . . . 
                    
                        org.apache.maven.plugins
                        maven-shade-plugin
                        2.4.1
                        
                            
                                
                                    *:*
                                    
                                        META-INF/*.SF
                                        META-INF/*.DSA
                                        META-INF/*.RSA
                                    
                                
                            
                            
                                
                            
                        
                        
                            
                                package
                                
                                    shade
                                
                            
                        
                        
                            
                                com.github.edwgiz
                                maven-shade-plugin.log4j2-cachefile-transformer
                                2.1
                            
                        
                    
                    . . . . . 
                
            . . . . . 
            
            . . . . . 
            
                
                    oss.sonatype.org
                    OSS Sonatype Staging
                    https://oss.sonatype.org/content/groups/staging
                
                  
            . . . . . 
        
    

提交回复
热议问题