Configure logging for Jetty's maven plugin?

后端 未结 2 949
感动是毒
感动是毒 2021-01-03 23:49

I\'m invoking the \"jetty:run\" goal with the following plugin configuration:


  org.mortbay.jetty
  

        
2条回答
  •  庸人自扰
    2021-01-04 00:19

    Extending Gili's answer a bit; using the properties-maven-plugin is a convenient way to set system properties instead of having to specify them on the command line. I provide examples for both logback and log4j. Add this plugin block to your pom.xml in addition to the jetty-maven-plugin configuration in Gili's answer.

    Logback:

    
      org.codehaus.mojo
      properties-maven-plugin
      1.0-alpha-2
      
        
          
            set-system-properties
          
          
            
              
              
                org.eclipse.jetty.util.log.IGNORED
                true
              
              
              
                logback.configurationFile
                /path/to/logback.xml
              
            
          
        
      
    
    

    Log4j:

    
      org.codehaus.mojo
      properties-maven-plugin
      1.0-alpha-2
      
        
          
            set-system-properties
          
          
            
              
              
                org.eclipse.jetty.util.log.IGNORED
                true
              
              
              
                log4j.configuration
                file:./src/main/resources/log4j.properties
              
              
              
            
          
        
      
    
    

    Also for log4j, naturally use the following dependency for the jetty-maven-plugin instead of logback-classic:

    
      org.mortbay.jetty
      jetty-maven-plugin
      ...
      
        
          org.slf4j
          slf4j-log4j12
          1.6.4
        
      
    
    

提交回复
热议问题