我正在使用Apache cxf处理Web服务,但在我的控制台和catalina.out中我有很多额外的日志,我使用logback进行日志记录。
我想关闭org.apache.cxf.services生成的日志记录soap消息,这是我的logback配置:
<!-- Standard Output logger -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<!-- File Appender -->
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/logs/output-log.log</file>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>1MB</maxFileSize>
</triggeringPolicy>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/logs/output-log-%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} %-5p [%-10.10t]
%60.60c:%-3L%m%n
</pattern>
</encoder>
</appender>
<logger name="org.apache.cxf" level="ERROR" additivity="false">
<appender-ref ref="AUDITTRAIL" />
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
<!-- appender-ref ref="SYSLOG" / -->
</logger>
<logger name="org.apache.cxf.interceptor" level="ERROR"
additivity="false" />
<logger name="org.apache.cxf.services" level="ERROR" additivity="false" />
<root level="INFO">
<appender-ref ref="AUDITTRAIL" />
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
<!-- appender-ref ref="SYSLOG" / -->
</root>
使用此配置我仍然在我的控制台日志和outlog文件示例中获取soap消息:
mars 30, 2018 9:55:00 AM org.apache.cxf.services.WebServiceImplService.StartImplPort.WebService
INFOS: Inbound Message
----------------------------
ID: 5
Address: http://127.0.0.1:8089/glsid/ws/webService
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml; charset=utf-8
Headers: {Accept=[text/xml, text/html, image/gif, image/jpeg,
.......
提前感谢帮助解决此问题
答案 0 :(得分:1)
最后这个解决方案对我有用:
文件中的:META-INF/cxf/org.apache.cxf.Logger
我添加了:org.apache.cxf.common.logging.Slf4jLogger
在spring配置中:applicationContext:
我补充说:
<bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<cxf:bus>
<cxf:inInterceptors>
<ref bean="loggingInInterceptor"/>
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="loggingOutInterceptor"/>
</cxf:outInterceptors>
</cxf:bus>
并在logback.xml中关闭STDOUT中的soap日志记录:
<!-- Apache CXF logger -->
<logger name="org.apache.cxf" level="INFO"/>
<logger name="org.apache.cxf.interceptor" additivity="false">
<!-- <appender-ref ref="STDOUT" /> -->
<appender-ref ref="FILE" />
</logger>
<root level="INFO">
<!-- <appender-ref ref="STDOUT" />-->
<appender-ref ref="FILE" />
</root>