使用Jetty maven插件进行logback访问

时间:2013-10-14 10:19:58

标签: java maven logback maven-jetty-plugin

我正试图在this之后使用码头进行回溯访问 但是,我在启动服务器时遇到此异常:

  

|的配置错误logback.xml |   抛出java.lang.ClassNotFoundException:   ch.qos.logback.access.jetty.RequestLogImpl

以下是导致问题的jetty.xml代码:

<Ref id="RequestLogHandler">
 <Set name="requestLog">
    <New id="requestLogImpl" class="ch.qos.logback.access.jetty.RequestLogImpl">
       <Set name="resource">as/classpath/resource/myaccess.xml</Set>
    </New>   
  </Set>
</Ref>

这是pom.xml

<dependencies>      
<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
  <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-access</artifactId>
        <version>1.0.13</version>
      </dependency>
      <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.0.13</version>
      </dependency>
  </dependencies>
 <build>
<finalName>oslc4j-jira-sample</finalName>
    <plugins>


    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>


        <configuration>
            <webAppConfig>
              <contextPath>/OSLC4JJira</contextPath>
            </webAppConfig>
              <!-- Jetty config adds logging -->
            <jettyConfig>${project.build.directory}/classes/jetty.xml</jettyConfig>

            <!-- enable hot deploy -->
            <reload>automatic</reload>
            <scanIntervalSeconds>5</scanIntervalSeconds>
            <scanTargets>
                <scanTarget>WebContent</scanTarget>
            </scanTargets>
                   <systemProperties>

                <systemProperty>
                    <name>config.dir</name>
                    <value>${basedir}/src/test/resources</value>
                </systemProperty>

                <systemProperty>
                    <name>jetty.logs</name>
                    <value>${basedir}/target</value>
                </systemProperty>
                <systemProperty>
                    <name>jetty.port</name>
                    <value>8080</value>
                </systemProperty>

            </systemProperties>
            <webResources>
        <resource>
          <directory>${build.sourceDirectory}</directory>
          <targetPath>sources</targetPath>
        </resource>
       </webResources>
<dependencies>
   <dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.0.13</version>
      </dependency>
</dependencies>
    </configuration>
    </plugin>
</plugins>

2 个答案:

答案 0 :(得分:0)

您通常必须这样做:“在下载logback发行版之后,将文件logback-core-VERSION.jar和logback-access-VERSION.jar放在$ JETTY_HOME / lib目录下,其中$ JETTY_HOME是您的文件夹安装了Jetty。版本的logback-access 0.9.31及更高版本的目标Jetty版本7.x和8.x.Logback-access版本0.9.30及更早版本的目标Jetty版本6.x.“但是你正在使用jetty maven插件:

您是否在jetty插件中添加了依赖项?:

<project>
  ...
  <build>
    ...
    <plugins>
      ...
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>8.0.4.v20111024</version><!-- or whatever version you specified -->
        <configuration>
          ...
        </configuration>
        ...
          <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.0.13</version>
          </dependency>
        ...
      </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>

答案 1 :(得分:0)

正如user2878524所说,这是一个错误link here