如何使用log4j2记录CXF Web服务请求? [英] How to log CXF webservice requests with log4j2?
本文介绍了如何使用log4j2记录CXF Web服务请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将所有传入和传出的 CXF
请求记录到特定的日志文件中。但是我使用以下配置获得的是控制台输出。这有什么问题?
I'd like to log all incoming and outgoing CXF
requests to a specific logfile. But all I get with the following configuration is a console output. What is wrong here?
log4j2.xml:
log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
</Console>
<RollingFile name="CXF" fileName="cxf.log">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
</RollingFile>
</Appenders>
<Loggers>
<logger name="org.apache.cxf" additivity="false" level="info">
<AppenderRef ref="CXF"/>
</logger>
<logger name="org.apache.cxf.interceptor.LoggingInInterceptor" additivity="false" level="info">
<AppenderRef ref="CXF" />
</logger>
<logger name="org.apache.cxf.interceptor.LoggingOutInterceptor" additivity="false" level="info">
<AppenderRef ref="CXF" />
</logger>
<Root level="all">
<AppenderRef ref="CONSOLE" />
</Root>
</Loggers>
</Configuration>
src / main / resources / META-INF / cxf / org.apache.cxf.Logger:
src/main/resources/META-INF/cxf/org.apache.cxf.Logger:
org.apache.cxf.common.logging.Log4jLogger
推荐答案
作为解决方法,我现在正在使用 org.apache.cxf.common.logging.Slf4jLogger
和桥梁依赖。
As a workaround, I'm now using org.apache.cxf.common.logging.Slf4jLogger
and the bridge dependency.
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.0</version>
</dependency>
这篇关于如何使用log4j2记录CXF Web服务请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文