为Jetty的Maven插件配置日志记录? [英] Configure logging for Jetty's maven plugin?
问题描述
我正在通过以下插件配置调用"jetty:run"目标:
I'm invoking the "jetty:run" goal with the following plugin configuration:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.4.4.v20110707</version>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>80</port>
</connector>
</connectors>
</configuration>
</plugin>
尽管我的项目将slf4j声明为依赖项,但Jetty拒绝将任何内容记录到slf4j.如果我将"-Dorg.eclipse.jetty.util.log.DEBUG = true"传递给JVM,Jetty将输出大量日志,但它们似乎是输入stderr而不是slf4j.有什么想法吗?
Jetty refuses to log anything to slf4j in spite of the fact that my project declares slf4j as a dependency. If I pass "-Dorg.eclipse.jetty.util.log.DEBUG=true" to the JVM, Jetty outputs tons of logs but they seem to go to stderr instead of to slf4j. Any ideas?
推荐答案
回答我自己的问题:
-
插件看不到项目依赖项.您需要在
<plugin>
中指定<dependencies>
.
您需要指定一个具体的slf4j实现,例如logback.指定slf4j是不够的.
You need to specify a concrete slf4j implementation, such as logback. Specifying slf4j is not enough.
最终结果应如下所示:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.4.4.v20110707</version>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>80</port>
</connector>
</connectors>
</configuration>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.29</version>
</dependency>
</dependencies>
</plugin>
这篇关于为Jetty的Maven插件配置日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!