Reputation: 985
In the application that am working on org.apache.cxf.interceptor.LoggingInInterceptor is currently logging HTTP request/responses into catalina.out.
I want it to somehow duplicate this info into a separate log file. Any pointers of how to do this?
Upvotes: 1
Views: 10470
Reputation: 255
The settings provided by OP's answer also worked for me(thanks!) however I had to change the LoggingOutInterceptor class name to the class that was was was running the service.
So instead of the following:
log4j.logger.org.apache.cxf.interceptor.LoggingOutInterceptor=INFO, queryLog
log4j.additivity.org.apache.cxf.interceptor.LoggingOutInterceptor=true
I needed to have this:
log4j.logger.org.apache.cxf.services=INFO, outgoingSOAPMessages
log4j.additivity.org.apache.cxf.services=true
Just thought I'd post in case it helps anyone in the future.
Upvotes: 0
Reputation: 985
Wanted to share final solution that worked nicely for me.
Added following to the application's log4j.properties
log4j.logger.org.apache.cxf.interceptor.LoggingOutInterceptor=INFO, queryLog
log4j.additivity.org.apache.cxf.interceptor.LoggingOutInterceptor=true
log4j.logger.org.apache.cxf.interceptor.LoggingInInterceptor=INFO, queryLog
log4j.additivity.org.apache.cxf.interceptor.LoggingInInterceptor=true
# Query log
log4j.appender.queryLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.queryLog.File=/C:/Eclipse-Tomcat/logs/query.log
log4j.appender.queryLog.layout=org.apache.log4j.PatternLayout
log4j.appender.queryLog.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
log4j.appender.queryLog.DatePattern = '.'yyyy-MM-dd
log4j.category.queryLogger=INFO, queryLog
This basically works great for me, input/output HTTP request responses are logged in catalina.out as well as query.log Logs get rotated daily as well.
Upvotes: 5
Reputation: 7301
Depending on the logging framework you are using, you should properly configure the log4j
, slf4j
or <tomcat>/conf/logging.properties
file to set a specific appender for the org.apache.cxf.interceptor.LoggingInInterceptor
class.
Upvotes: 2
Reputation: 3132
According to the Javadoc, you could declare a new PrintWriter in the LoggingInInterceptor constructor :
File file = new File("/directory/mylogs.txt");
file.getParentFile().mkdirs();
PrintWriter printWriter = new PrintWriter(file);
LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor(printWriter);
Upvotes: 1