Tôi tra cứu tất cả thư nhưng không tìm thấy câu trả lời rõ ràng cho câu hỏi đó.cxf đăng nhập thư đến và gửi đi vào tệp nhật ký riêng
Làm cách nào tôi có thể định cấu hình ghi nhật ký để đăng nhập CXF thư gửi đến và gửi đi?
Tôi có thiết lập sau.
file org.apache.cxf.Logger với
org.apache.cxf.common.logging.Log4jLogger
applicationContext.xml có như sau (nó có vẻ ngớ ngẩn, nhưng nó là nơi duy nhất để chặn tôi có thể nhận được tin nhắn đầu ra)
<bean id="abstractLoggingInterceptor" abstract="true"> <property name="prettyLogging" value="true"/> </bean> <bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" parent="abstractLoggingInterceptor"/> <bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" parent="abstractLoggingInterceptor"/> <cxf:bus> <cxf:inInterceptors> <ref bean="loggingInInterceptor"/> </cxf:inInterceptors> <cxf:outInterceptors> <ref bean="loggingOutInterceptor"/> </cxf:outInterceptors> <cxf:outFaultInterceptors> <ref bean="loggingOutInterceptor"/> </cxf:outFaultInterceptors> <cxf:inFaultInterceptors> <ref bean="loggingInInterceptor"/> </cxf:inFaultInterceptors> </cxf:bus>
tôi cố gắng để làm theo các hướng dẫn với slf4j và với log4j, nhưng đầu ra duy nhất tôi vào tập tin là thông điệp nhật ký ứng dụng. Tôi có thể xem tin nhắn trong và ngoài trên bảng điều khiển của mình.
Tôi có thể nhận được một cái gì đó tương tự như logback.xml làm việc cho tôi, vì vậy tôi tách nhật ký ứng dụng và nhật ký thư. Ví dụ: http://www.wolfe.id.au/2011/05/20/apache-cxf-logging/
Cảm ơn.
CHỈNH SỬA 1: Tôi đã xóa org.apache.cxf.common.logging.Log4jLogger khỏi đường dẫn lớp của mình và đặt thông tin sau vào log4j.xml của mình. Nó ghi vào tệp và điều khiển khi mức ghi nhật ký bằng INFO.
<appender name="RSLOGFILE" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="${project.basedir}/logs/cxf_inout_messages.log"/>
<param name="MaxFileSize" value="100KB"/>
<!-- Keep one backup file -->
<param name="MaxBackupIndex" value="1"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- Print the date in ISO 8601 format -->
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<logger name="org.apache.cxf">
<level value="ERROR"/>
<appender-ref ref="RSLOGFILE"/>
</logger>
Mọi thứ ở đây đều tốt, chỉ cần một chút lưu ý: Hãy nhớ đặt "META-INF/cxf/org.apache.cxf.Logger" trong ví dụ src/main/resources thay vì "src/main/webapp" như tôi đa lam. Bằng cách đó nó sẽ được theo classpath. –