2017-07-16 40 views
0

我试图从Jetty Maven插件版本9查看详细的调试信息以诊断无关的错误。我看过一篇描述版本7的帖子Configure logging for Jetty's maven plugin?,另一篇帖子Use Log4j with jetty-maven-plugin 9.x描述了使用logback进行日志记录。我已经尝试过提到的建议,包括在命令行中和pom.xml中的插件配置下设置各种系统属性。我也尝试在pom.xml的插件下添加各种依赖项。似乎没有任何建议可行,而且我想知道是否我在做最新版本的错误或改变。无论我输入什么,标准输出中都不会显示详细的日志信息。 (见下文)。在这一点上,我甚至不需要与logback或log4j进行集成。我需要的只是任何类型的日志 - 标准输出或标准错误都可以。我知道我缺少一些非常基本的东西。以下是相关信息。为Jetty Maven插件登录标准输出版本9

命令:

mvn jetty:run 

的pom.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" 
    xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 

<modelVersion>4.0.0</modelVersion> 
<groupId>me.question</groupId> 
<artifactId>question1</artifactId> 
<version>1.0.1-SNAPSHOT</version> 
<packaging>war</packaging> 

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 


<build> 
    <plugins> 

     <plugin> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-maven-plugin</artifactId> 
      <version>9.4.6.v20170531</version> 
      <configuration> 
       <webApp> 

        <!-- 
        <defaultsDescriptor>src/main/webapp/resources/webdefault.xml</defaultsDescriptor> 
        --> 
       </webApp> 
       <httpConnector> 
        <port>8080</port> 
       </httpConnector> 
       <stopKey>jetty-stop</stopKey> 
       <stopPort>54326</stopPort> 

       <systemProperties> 


       </systemProperties> 
      </configuration> 

      <dependencies> 

      </dependencies> 

     </plugin> 

    </plugins> 
</build> 

标准出来:

[INFO] jetty-9.4.6.v20170531 
[INFO] Scanning elapsed time=41ms 
[INFO] DefaultSessionIdManager workerName=node0 
[INFO] No SessionScavenger set, using defaults 
[INFO] Scavenging every 660000ms 
[INFO] Started [email protected]{/,file:///Users/me/projects/log/src/main/webapp/,AVAILABLE}{file:///Users/me/projects/log/src/main/webapp/} 
[INFO] Started [email protected]{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} 
[INFO] Started @2055ms 
[INFO] Started Jetty Server 

回答

0

我想通了,出了什么问题。我试图在jetty-maven-plugin中设置系统属性,而不是事先使用properties-maven-plugin。下面是我在我的pom.xml中的内容:

 <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>properties-maven-plugin</artifactId> 
      <version>1.0.0</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>set-system-properties</goal> 
        </goals> 
        <configuration> 
         <properties> 
          <property> 
           <name>org.eclipse.jetty.util.log.class</name> 
           <value>org.eclipse.jetty.util.log.StdErrLog</value> 
          </property> 
          <property> 
           <name>org.eclipse.jetty.LEVEL</name> 
           <value>DEBUG</value> 
          </property> 
         </properties> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-maven-plugin</artifactId> 
      <version>9.3.20.v20170531</version> 
      <configuration> 
       <webApp> 
        <baseResource implementation="org.eclipse.jetty.util.resource.ResourceCollection"> 
         <resourcesAsCSV> 
          src/main/webapp 
         </resourcesAsCSV> 
        </baseResource> 
       </webApp> 
       <httpConnector> 
        <port>8080</port> 
       </httpConnector> 
       <useTestScope>false</useTestScope> 
       <stopKey>foo</stopKey> 
       <stopPort>52042</stopPort> 
      </configuration> 
     </plugin>