我目前正在尝试使用slf4j为jetty 8配置集中日志记录。我发现以下[教程][1],但它似乎不与jetty 8工作。有人知道怎么用jetty 8吗?
解决方案:
jetty-webapp-logging.xml必须包含以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<!-- =============================================================== -->
<!-- Enable Centralized Logging in the Jetty Server -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Ref id="DeploymentManager">
<Call name="addLifeCycleBinding">
<Arg>
<New class="org.mortbay.jetty.webapp.logging.CentralizedWebAppLoggingBinding">
</New>
</Arg>
</Call>
</Ref>
</Configure>
虽然该教程是为Jetty 9创建的,但它使用的所有特性也可以在Jetty 8.1.10上使用。
一些建议:
- 使用Jetty 8.1.10版本的Jetty -webapp-logging jar。
- 在处理XML文件时使用正确版本的DOCTYPE
- 使用
start.jar
的命令行相同。 -
start.ini
变化相同
最后,可以在
找到各种日志示例https://github.com/jetty-project/jetty-and-logback-example(提示:构建maven项目,然后在各种${module}/target/jetty-distro/
中查找这些maven构建产生的配置发行版)