我想将所有传入和传出的CXF
请求记录到特定的日志文件中。但是我使用以下配置获得的是控制台输出。这有什么不对?
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 /主/资源/ META-INF / CXF / org.apache.cxf.Logger:
org.apache.cxf.common.logging.Log4jLogger
答案 0 :(得分:5)
作为一种解决方法,我现在使用org.apache.cxf.common.logging.Slf4jLogger
和桥接器依赖。
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.0</version>
</dependency>
答案 1 :(得分:1)
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Properties>
<property name="multiplan">logs/multiplan.log</property>
<property name="webservice">logs/webservice.log</property>
<property name="sql">logs/sql.log</property>
<property name="mongoexceptions">logs/mongoexceptions.log</property>
</Properties>
<Appenders>
<RollingFile name="mongoexceptions-all" fileName="${mongoexceptions}"
filePattern="${mongoexceptions}.%i" bufferedIO="false" bufferSize="8192">
<PatternLayout>
<pattern>%d{dd MMM HH:mm:ss:SSS} %p [%t] - %m ---- %c%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="10000KB" />
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
<RollingFile name="multiplan-all" fileName="${multiplan}"
filePattern="${multiplan}.%i" bufferedIO="false" bufferSize="8192">
<PatternLayout>
<pattern>%d{dd MMM HH:mm:ss:SSS} %p [%t] - %m ---- %c%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="10000KB" />
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingFile>
<RollingFile name="webservice-all" fileName="${webservice}" filePattern="${webservice}.%i" bufferedIO="false" bufferSize="8192">
<PatternLayout>
<pattern>%d{dd MMM HH:mm:ss:SSS} %p [%t] - %m %n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="10000KB" />
</Policies>
<DefaultRolloverStrategy max="5"/>
</RollingFile>
<RollingFile name="sql-all" fileName="${sql}" filePattern="${sql}.%i" bufferedIO="true" bufferSize="8192">
<PatternLayout pattern="%d [%t] %-5p %c - %m%n" />
<Policies>
<SizeBasedTriggeringPolicy size="1000KB" />
</Policies>
<DefaultRolloverStrategy max="1"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="info" additivity="false">
<AppenderRef ref="multiplan-all"/>
</Root>
<Logger name="org.apache.cxf" additivity="false" level="warn">
<appender-ref ref="multiplan-all"/>
</Logger>
<Logger name="org.springframework" additivity="false" level="warn">
<appender-ref ref="multiplan-all"/>
</Logger>
<Logger name="org.eclipse.jetty" additivity="false" level="warn">
<appender-ref ref="multiplan-all"/>
</Logger>
<Logger name="com.multiplan.bam.db.edp.EventAuditDAO" level="error" additivity="false">
<appender-ref ref="mongoexceptions-all" />
</Logger>
<Logger name="com.multiplan.bam.db.edp.ExceptionsLogDAO" level="error" additivity="false">
<appender-ref ref="mongoexceptions-all" />
</Logger>
<Logger name="com.multiplan.bam.db.edp.ClaimDAO" level="debug">
<appender-ref ref="webservice-all" />
</Logger>
<Logger name="com.multiplan.bam.db.edp.CPDSummaryDAO" level="debug">
<appender-ref ref="webservice-all" />
</Logger>
<Logger name="DBConnectionFactory" level="info">
<appender-ref ref="sql-all"/>
</Logger>
</Loggers>
</Configuration>
以下是工作示例。