简体   繁体   中英

logback access with Jetty maven plugin

I am trying to use logback access with jetty following this However I am getting this exception when starting the server:

Config error at | logback.xml | java.lang.ClassNotFoundException: ch.qos.logback.access.jetty.RequestLogImpl

Here is the code from jetty.xml causing the problem :

<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>

and here is the 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>

You normaly have to do that :"After downloading the logback distribution, place the files logback-core-VERSION.jar and logback-access-VERSION.jar under $JETTY_HOME/lib directory, where $JETTY_HOME is the folder where you have installed Jetty. Versions of logback-access 0.9.31 and later target Jetty versions 7.x and 8.x. Logback-access versions 0.9.30 and earlier target Jetty version 6.x." but you're using the jetty maven plugin so:

Did you add the dependency in the jetty plugin?:

<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>

正如user2878524所说的,这是一个错误链接

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM