Child pages
  • Remote Logging

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Instructions for setting up remote logging in CXF using mDNS/Chainsaw

This will let you connect to a CXF container running on your local subnet and view incoming and outgoing messages to services

Set up Logging in the service

  • Ensure that your classpath service includes: (both available from here: https://alis.cs.bath.ac.uk/svn/alive-code/alive-common-deps/trunk/log4j/
    • jmdns.jar
    • log4j-zeroconf.jar
    • log4j-1.2.14.jar
  • In your web service classpath (e.g. webroot/WEB-INF/classes) create a file META-INF/cxf/org.apache.cxf.Logger and put the following into it:
    Code Block
    org.apache.cxf.common.logging.Log4jLogger
  • If you don't already have a log4j.properties file in your service classpath create one.
  • Add an mDNS logger to your log4j.properties as follows:
    Code Block
    log4j.rootCategory=INFO,zeroconf
    log4j.appender.zeroconf=org.apache.log4j.net.ZeroConfSocketHubAppender
    
    # Stdout
    log4j.appender.zeroconf.name=CJServices
    log4j.appender.zeroconf.port=4560
    
  • The port log4j.appender.zeroconf.port MUST be unique on the local machine - that is the port the log aggregator will listen on. It can be set to anything you like.
  • In your service beans xml file add a logging interceptor:
    Code Block
    <beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:cxf="http://cxf.apache.org/core"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
    	xmlns:jaxrs="http://cxf.apache.org/jaxrs"
    	xsi:schemaLocation="
    http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
    http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
    
    	<import resource="classpath:META-INF/cxf/cxf.xml" />
    	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    	<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
    	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
    
    
    	<bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor" />
    	<bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
    
    	<cxf:bus>
    		<cxf:inInterceptors>
    			<ref bean="logInbound" />
    		</cxf:inInterceptors>
    		<cxf:outInterceptors>
    			<ref bean="logOutbound" />
    		</cxf:outInterceptors>
    		<cxf:outFaultInterceptors>
    			<ref bean="logOutbound" />
    		</cxf:outFaultInterceptors>
    		<cxf:inFaultInterceptors>
    			<ref bean="logInbound" />
    		</cxf:inFaultInterceptors>
    	</cxf:bus>
    
    
    
    	<jaxws:endpoint id="CalculateAppropateChannelService"
    		implementorClass="uk.co.calicojack.alive.services.CalculateAppropriateChannelServiceWrapper"
    		address="/CalculateAppropriateChannelService">
    		<jaxws:implementor>
    			<bean
    				class="uk.co.calicojack.alive.services.CalculateAppropriateChannelServiceWrapper">
    				<constructor-arg ref="serviceFactory" />
    			</bean>
    		</jaxws:implementor>
    	</jaxws:endpoint>
    
    
  • deploy and start the service

Set up the logging monitor

  • download Chainsaw 2.0
  • Open chainsaw (I had a problem with the HTML display and the tooltip window being weird) - this must be running on the same subnet as the service
  • Click on the ZeroConf tab, you should see the logging service defined above.
  • Double click on the zeroconf entry and connect
  • Nothing will be displayed until you have some log messages
  • When the service has been invoked you can drill-down on the specific interceptor logs by selecting the org/apache/cxf/interceptor branch, right clicking and selecting "Focus on org.apache.cxf.interceptor"
  • You should then see live incoming and outgoing messages

Caveats

I don't think the MDNS logger likes to be reloaded so you might have to restart tomcat rather than reload the service