Ale*_*sev 6 java jersey logback jersey-1.0 jul-to-slf4j
我有一个项目,我使用:
我需要记录请求和响应。为了实现它,我将 LoggingFilter 添加到我的web.xml:
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud)
我在 Eclipse 中运行项目并在 Eclipse 控制台看到日志记录。
现在,我想使用 Logback 编写日志文件并使用自定义附加程序,所以我添加到我的pom.xml:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.13</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.7.13</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
要将所有 JUL 日志记录路由到 SLF4J API,我使用 org.slf4j.bridge.SLF4JBridgeHandler
我尝试通过创建src/main/resources/logging.properties内容来安装 SLF4JBridgeHandler :
handlers = org.slf4j.bridge.SLF4JBridgeHandler
Run Code Online (Sandbox Code Playgroud)
正如它在这里提到的,没有发生任何事情。
如果我使用另一种方法(程序安装),一切正常。
为什么它不适用于logging.properties配置?我错过了什么?
该logging.properties文件应驻留在文件系统上(而不是类路径上)。它的路径应该通过系统属性指定java.util.logging.config.file:
java -Djava.util.logging.config.file=/path/to/logging.properties ...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
453 次 |
| 最近记录: |