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

前端 未结 6 2211
栀梦
栀梦 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:52

    You don't need the maven-resources-plugin if you have a simple environment.

    In this example, log4j.properties B is the file you use for production and is in the directory src/main/java and log4j.properties A is the file you use for development and is in the directory /Users/junger/.m2/.

    In your pom.xml:

    
        src/main/java
    
    
    
        
            
                ${log4j.properties.directory}
                
                    log4j.properties
                
            
        
    
    

    Now, in your /Users/junger/.m2/settings.xml (create one if it doesn't exist):

    
        
            dev
            
                true
            
            
                /Users/devuser/.m2/
            
        
    
    

    By using this method, each developer can have a different log4j.properties directory and you keep your pom.xml clean.

提交回复
热议问题