如何配置jetty-maven-plugin来记录oejs,oejsh,oejsh包

时间:2012-03-14 18:07:30

标签: plugins maven logging jetty

我正在尝试配置jetty-maven-plugin 8.0.3.v20111011。 我正在运行部署战争目标。与demon = true。

我无法看到来自oejs,oejsh,oejsh包的日志。

为了获取日志,我尝试了两种方式。

1>为插件设置log4j 2 - ;设置stdOut和StdErr ...但是我仍然无法获取日志

以下是我的POM,log4j.properties和jetty-logging.xml

    <plugin>  
        <groupId>org.mortbay.jetty</groupId>  
        <artifactId>jetty-maven-plugin</artifactId>  
        <version>8.0.3.v20111011</version>  
        <configuration>  
            <systemProperties>                          
                <systemProperty>  
                    <name>org.apache.commons.logging.Log</name>  
                    <value>org.apache.commons.logging.impl.Log4JLogger</value>  
                </systemProperty>  
                <systemProperty>  
                    <name>slf4j</name>  
                    <value>false</value>  
                </systemProperty>  
                <systemProperty>  
                    <name>log4j.configuration</name>  
                    <value>file:///${project.basedir}/src/test/resources/log4j.properties</value>  
                </systemProperty>  
                <systemProperty>  
                    <name>jetty.logs</name>  
                    <value>.</value>  
                </systemProperty>  
            </systemProperties>  
            <war>${deploy.war}</war>  
            <webApp>  
                <contextPath>${server.basePath}</contextPath>  
            </webApp>  
            <connectors>  
                <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">  
                    <port>${server.run.port}</port>  
                </connector>  
            </connectors>  
            <stopPort>${server.stop.port}</stopPort>  
            <stopKey>hola</stopKey>  
            <jettyConfig>th-integration/src/test/resources/jetty-logging.xml</jettyConfig>  
        </configuration>  
        <executions>  
            <execution>  
                <id>start-jetty</id>  
                <phase>pre-integration-test</phase>  
                <goals>  
                    <goal>deploy-war</goal>  
                </goals>  
                <configuration>  
                    <daemon>true</daemon>  
                    <reload>manual</reload>  
                </configuration>  
            </execution>  
            <execution>  
                <id>stop-jetty</id>  
                <phase>post-integration-test</phase>  
                <goals>  
                    <goal>stop</goal>  
                </goals>  
            </execution>  
        </executions>                  
    </plugin>  

    log4j.rootCategory=DEBUG, server  
    log4j.appender.server=org.apache.log4j.FileAppender  
    log4j.appender.server.File=jetty_log4j.log  
    log4j.appender.server.layout=org.apache.log4j.PatternLayout  
    log4j.appender.server.layout.ConversionPattern=%d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - %m%n  
    log4j.logger.org.mortbay.log=DEBUG  
    log4j.logger.oejsh.ContextHandler=DEBUG  
    log4j.logger.oejd.DeploymentManager=DEBUG  
    log4j.logger.oejs.ServletHandler=DEBUG  
    log4j.logger.oejs.AbstractConnector=DEBUG  

<?xml version="1.0"?>  
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">  
<Configure id="Server" class="org.eclipse.jetty.server.Server">  
    <!--Configure id="Server" class="org.mortbay.jetty.plugin.JettyServer"-->  
    <New id="ServerLog" class="java.io.PrintStream">  
        <Arg>  
            <New class="org.eclipse.jetty.util.RolloverFileOutputStream">  
                <Arg>yyyy_mm_dd.jetty_console.log</Arg>  
                <Arg type="boolean">false</Arg>  
                <Arg type="int">90</Arg>  
                <Arg>  
                    <Call class="java.util.TimeZone" name="getTimeZone">  
                        <Arg>GMT</Arg>  
                    </Call>  
                </Arg>  
                <Get id="ServerLogName" name="datedFilename"/>  
            </New>  
        </Arg>  
    </New>    
    <Call class="org.eclipse.jetty.util.log.Log" name="info">  
        <Arg>Redirecting stderr/stdout to  
            <Ref id="ServerLogName"/>  
        </Arg>  
    </Call>  
    <Call class="java.lang.System" name="setErr">  
        <Arg>  
            <Ref id="ServerLog"/>  
        </Arg>  
    </Call>  
    <Call class="java.lang.System" name="setOut">  
        <Arg>  
            <Ref id="ServerLog"/>  
        </Arg>  
    </Call>  
</Configure>  

1 个答案:

答案 0 :(得分:2)

您需要将org.eclipse.jetty.LEVEL设置为DEBUG

在命令行上你只需使用-Dorg.eclipse.jetty.LEVEL = DEBUG所以我认为你的问题是你不应该将你的配置中的包名缩短为oejs,我们在输出上只是为了节省一些space,实际级别是实际的包名。