How to configure maven to use different log4j.properties files in different environments

前端 未结 6 2214
栀梦
栀梦 2020-12-05 14:23

I want to be able to use different log4j configuration for different environments.

In my development environment, I want to use log4j.properties (A). But when I bui

6条回答
  •  感动是毒
    2020-12-05 14:46

    1. in your project add 3 folders : 
    
      Your Project\src\main\resources\
    
                \A > log4j.properties
                \B > log4j.properties
                \Default > log4j.properties
    2. in pom.xml         
    
           
                    Default 
            
    
            
                
                    
                        src/main/resources/${param}           
                    
                
             
    
    3. 
    
     - if : mvn clean install : classpath => log4j.properties(Default)
    
     - if : mvn clean install  -Dparam=A : classpath => log4j.properties(A)
    
     - if : mvn clean install  -Dparam=B : classpath => log4j.properties(B)
    
    
    > much better than using profiles is more extensible without touching the pom
    

提交回复
热议问题