记录Jetty Maven插件版本9的标准输出

时间:2017-07-16 21:37:34

标签: maven logging jetty maven-jetty-plugin

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

命令:

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 o.e.j.m.p.JettyWebAppContext@25b865b5{/,file:///Users/me/projects/log/src/main/webapp/,AVAILABLE}{file:///Users/me/projects/log/src/main/webapp/}
[INFO] Started ServerConnector@6abae708{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started @2055ms
[INFO] Started Jetty Server

1 个答案:

答案 0 :(得分: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>