Search code examples
loggingsoapapache-axisintershop

Axis2 logging SOAP request and response with logback truncates to 4000 characters(bytes)


We are trying to log Axis2 SOAP log messages with logback and following configuration:

<!-- Axis client appender -->
<appender name="AxisLogging" class="ch.qos.logback.core.rolling.RollingFileAppender">
  <filter class="ch.qos.logback.classic.filter.LevelFilter">
    <level>INFO</level>
    <OnMatch>ACCEPT</OnMatch>
    <OnMismatch>NEUTRAL</OnMismatch>
  </filter>
  <filter class="ch.qos.logback.classic.filter.LevelFilter">
    <level>DEBUG</level>
    <OnMatch>ACCEPT</OnMatch>
    <OnMismatch>NEUTRAL</OnMismatch>
  </filter>
  <filter class="ch.qos.logback.classic.filter.LevelFilter">
    <level>TRACE</level>
    <OnMatch>ACCEPT</OnMatch>
    <OnMismatch>DENY</OnMismatch>
  </filter>

  <File>log/axis-client.log</File>
  <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
    <FileNamePattern>log/axis-client.%i.log</FileNamePattern>
    <MinIndex>1</MinIndex>
    <MaxIndex>5</MaxIndex>
  </rollingPolicy>
  <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
    <MaxFileSize>100MB</MaxFileSize>
  </triggeringPolicy>

  <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
    <layout class="ch.qos.logback.classic.PatternLayout">
        <Pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS zZ}] %-5level [%mdc{requestsite}] [%mdc{session.id}] "%thread" %msg %ex%n</Pattern>
    </layout>
  </encoder>
</appender>

<logger name="httpclient.wire.content">
  <appender-ref ref="AxisLogging"/>
</logger>

And log messages of long request, and response XML are truncated on 4000 characters, and spreads through multiple log lines. Is there any way to configure logback to log whole XML in one log line?

Thanks!


Solution

  • Apperently this is issue with ReaderConfig.java (com.ctc.wstx.api.ReaderConfig.java) which is responsible for reading (and logging web service response). As you can see here:

    https://github.com/FasterXML/woodstox/blob/master/src/main/java/com/ctc/wstx/api/ReaderConfig.java

    In method createFullDefaults() which is called on server start by com.ctc.wstx.stax.WstxInputFactory, Reader is constructed with fixed buffer length of 4000.

    So logging with custom code is only solution if you want full Axis2 response XML message in one line.