ip696
ip696

Reputation: 7084

Log management in cxf + spring boot

I have Spring boot server and it work like proxy. It is SOAP service and SOAP client. user call soap service on my server and my server call another soap service. Bouth services use one WSDL. My server implement this WSDL and acts as server for clients. And my server use this WSDL for requests to another server and acts as client for another server.

Client -> WSDL -> My server -> WSDL -> Another server
           |                     |  
           |------same WSDL------|

I need manage SOAP logs but I have problems. For example I can add to logback next lines:

  <logger name="org.apache.cxf.services.MessageExchangePortType.REQ_IN" level="ERROR" />
  <logger name="org.apache.cxf.services.MessageExchangePortType.RESP_IN" level="ERROR" />

  <logger name="org.apache.cxf.services.MessageExchangePortType.REQ_OUT" level="INFO" />
  <logger name="org.apache.cxf.services.MessageExchangePortType.RESP_OUT" level="INFO" /> 

But this way I manage logs for both incoming and outgoing messages.

Because my service and client use MessageExchangePortType.

How can I manage each client/server logs?

This is implementation of client:

    @Bean(name = "MessageExchangeClient")
    public MessageExchangePortType signingPortType() {
        JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
        jaxWsProxyFactoryBean.setServiceClass(MessageExchangePortType.class);
        jaxWsProxyFactoryBean.setAddress(host);
        jaxWsProxyFactoryBean.getInInterceptors().add(new LoggingInInterceptor());
        jaxWsProxyFactoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
        jaxWsProxyFactoryBean.getOutInterceptors().add(new FaultOutInterceptor());
        jaxWsProxyFactoryBean.getOutInterceptors().add(new FaultOutInterceptor());
        return (MessageExchangePortType) jaxWsProxyFactoryBean.create();
    }

This is implementation of server:

Component
@Slf4j
@SchemaValidation(type = SchemaValidation.SchemaValidationType.IN)
public class MyEndpoint implements MessageExchangePortType {

and in config:

@Configuration
public class WebServiceConfiguration {

    @Value("${server.path}")
    private String path;

    private final Bus bus;
    private final MyEndpoint myEndpoint;

    @Autowired
    public WebServiceConfiguration(Bus bus, MyEndpoint myEndpoint) {
        this.bus = bus;
        this.myEndpoint= myEndpoint;
    }

    @Bean
    Endpoint endpoint() {

        EndpointImpl endpoint = new EndpointImpl(bus, myEndpoint);

        endpoint.getInInterceptors().add(new SAAJInInterceptor());

        LoggingFeature loggingFeature = new LoggingFeature();
        loggingFeature.setVerbose(true);
        loggingFeature.setLogMultipart(true);
        loggingFeature.setPrettyLogging(true);
        endpoint.getFeatures().add(loggingFeature);

        endpoint.publish(path);

        return endpoint;
    }
}

I want for example disable REQ_IN logs on client and enable on server but if I write: <logger name="org.apache.cxf.services.MessageExchangePortType.REQ_IN" level="ERROR" />

I set ERROR level to client and to server because MessageExchangePortType use client and server.

Upvotes: 0

Views: 3616

Answers (1)

Dennis Kieselhorst
Dennis Kieselhorst

Reputation: 1397

Implement your own type of org.apache.cxf.ext.logging.event.LogEventSender and change the categories. Look at org.apache.cxf.ext.logging.slf4j.Slf4jEventSender for the implementation that you are using by default to get an idea how to implement that.

Upvotes: 1

Related Questions