1

我目前正在尝试使用 slf4j 为 jetty 8 配置集中式日志记录。我找到了以下 [tutorial][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>
4

1 回答 1

1

虽然教程,使用 Logback 集中记录,是为 Jetty 9 创建的,但它使用的所有功能在 Jetty 8.1.10 上也可用。

一些忠告:

  1. 为 Jetty 8.1.10使用正确版本的 jetty-webapp-logging jar。
  2. 使用XML 文件时使用正确版本的 DOCTYPE 。
  3. 使用的命令行start.jar是一样的。
  4. start.ini变化是一样的。

最后,可以在以下位置找到各种日志记录示例

https://github.com/jetty-project/jetty-and-logback-example

(提示:构建 maven 项目,然后查看${module}/target/jetty-distro/这些 maven 构建产生的配置分布)

于 2013-05-11T14:10:58.537 回答