You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Andrew Clegg <an...@nervechannel.com> on 2009/06/23 14:33:56 UTC

In and out logging -- can't get it to work

Hi folks,

I'm trying to set up request/response logging via log4j, as described here:

http://cwiki.apache.org/CXF20DOC/debugging.html

and elaborated on here:

http://www.techper.net/2008/01/30/configuring-cxf-logging-to-go-through-log4j/

However, it's not playing nice...

I have the following stanza in my cxf-servlet.xml:

	<cxf:bus>
		<cxf:features>
			<cxf:logging />
		</cxf:features>
	</cxf:bus>

(where cxf="http://cxf.apache.org/core")

I have a file org.apache.cxf.Logger which contains the following line:

org.apache.cxf.common.logging.Log4jLogger

This ends up at WEB-INF/classes/META-INF/cxf/org.apache.cxf.Logger
relative to the root of the web app.

And my log4j.properties looks like this:

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.maxFileSize=10240KB
log4j.appender.file.maxBackupIndex=5
log4j.appender.file.File=/var/log/EMBRACE/enfin-war.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p [%t]
%c{1}:%L - %m%n
log4j.rootLogger=info, file
log4j.logger.org.apache.cxf.interceptor.LoggingInInterceptor=info, file
log4j.logger.org.apache.cxf.interceptor.LoggingOutInterceptor=info, file

I know CXF is using log4j because I get messages in enfin-war.log like:

2009-06-23 13:12:47,565  INFO [http-8080-1] ServerImpl:91 - Setting
the server's publish address to be /EnfinFuncNetService

But there's no sign of the SOAP messages.

I tried replacing the bus feature in CXF's config with explicit bean
definitions:

    <bean id="logInbound"
class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
    <bean id="logOutbound"
class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
	
    <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl">
        <property name="inInterceptors">
            <list>
                <ref bean="logInbound"/>
            </list>
        </property>
        <property name="outInterceptors">
            <list>
                <ref bean="logOutbound"/>
            </list>
        </property>
        <property name="outFaultInterceptors">
            <list>
                <ref bean="logOutbound"/>
            </list>
        </property>
    </bean>

Now I get the following acknowledgement in enfin-war.log that this is
being read OK:

2009-06-23 13:26:54,390  INFO [http-8080-1]
DefaultListableBeanFactory:414 - Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@52ae76:
defining beans [EnfinFuncNetService,logInbound,logOutbound,cxf];
parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@22c5e6

... but still no message logging. Any ideas?

Thanks yet again in advance,

Andrew.

-- 
:: http://biotext.org.uk/ ::

Re: In and out logging -- can't get it to work

Posted by Daniel Kulp <dk...@apache.org>.
I just committed some changes to trunk (will get on 2.2.x branch shortly) that 
will PROBABLY fix this.    The issue is cxf:bus ends  up creating a new bus 
which may not really be the on that is used for everything else.  I've changed 
the cxf:bus parser stuff to configure the existing bus which should fix this 
and a TON of other related issues.

Dan


On Tue June 23 2009 8:33:56 am Andrew Clegg wrote:
> Hi folks,
>
> I'm trying to set up request/response logging via log4j, as described here:
>
> http://cwiki.apache.org/CXF20DOC/debugging.html
>
> and elaborated on here:
>
> http://www.techper.net/2008/01/30/configuring-cxf-logging-to-go-through-log
>4j/
>
> However, it's not playing nice...
>
> I have the following stanza in my cxf-servlet.xml:
>
> 	<cxf:bus>
> 		<cxf:features>
> 			<cxf:logging />
> 		</cxf:features>
> 	</cxf:bus>
>
> (where cxf="http://cxf.apache.org/core")
>
> I have a file org.apache.cxf.Logger which contains the following line:
>
> org.apache.cxf.common.logging.Log4jLogger
>
> This ends up at WEB-INF/classes/META-INF/cxf/org.apache.cxf.Logger
> relative to the root of the web app.
>
> And my log4j.properties looks like this:
>
> log4j.appender.file=org.apache.log4j.RollingFileAppender
> log4j.appender.file.maxFileSize=10240KB
> log4j.appender.file.maxBackupIndex=5
> log4j.appender.file.File=/var/log/EMBRACE/enfin-war.log
> log4j.appender.file.layout=org.apache.log4j.PatternLayout
> log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p [%t]
> %c{1}:%L - %m%n
> log4j.rootLogger=info, file
> log4j.logger.org.apache.cxf.interceptor.LoggingInInterceptor=info, file
> log4j.logger.org.apache.cxf.interceptor.LoggingOutInterceptor=info, file
>
> I know CXF is using log4j because I get messages in enfin-war.log like:
>
> 2009-06-23 13:12:47,565  INFO [http-8080-1] ServerImpl:91 - Setting
> the server's publish address to be /EnfinFuncNetService
>
> But there's no sign of the SOAP messages.
>
> I tried replacing the bus feature in CXF's config with explicit bean
> definitions:
>
>     <bean id="logInbound"
> class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
>     <bean id="logOutbound"
> class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
>
>     <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl">
>         <property name="inInterceptors">
>             <list>
>                 <ref bean="logInbound"/>
>             </list>
>         </property>
>         <property name="outInterceptors">
>             <list>
>                 <ref bean="logOutbound"/>
>             </list>
>         </property>
>         <property name="outFaultInterceptors">
>             <list>
>                 <ref bean="logOutbound"/>
>             </list>
>         </property>
>     </bean>
>
> Now I get the following acknowledgement in enfin-war.log that this is
> being read OK:
>
> 2009-06-23 13:26:54,390  INFO [http-8080-1]
> DefaultListableBeanFactory:414 - Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@52ae76
>: defining beans [EnfinFuncNetService,logInbound,logOutbound,cxf];
> parent:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@22c5e6
>
> ... but still no message logging. Any ideas?
>
> Thanks yet again in advance,
>
> Andrew.

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog