4

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!

Goran Petanjek
  • 444
  • 2
  • 11

2 Answers2

2

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.

Goran Petanjek
  • 444
  • 2
  • 11
0

Are you sure the limit is in logback? Maybe the limitation is in axis2. Note: In this example the limitation is in the apache CXF library.

Text length limit in logback logging

This is how I usually log soap messages. Does require some programming though.

String request = stub._getServiceClient().getLastOperationContext().getMessageContext("Out")
              .getEnvelope().toString());
String response = stub._getServiceClient().getLastOperationContext().getMessageContext("In")
              .getEnvelope().toString());

If you write those vars to the log then you shouldn't have a problem.

Willem Evertse
  • 1,219
  • 7
  • 16
  • I think it's logback, but can't be sure. Problem is that we don't won't to write our custom log messages for every web service request/response because we have around 100 calls, and would like to log them automatically :) We just trying to find a way to remove limit of 4000 characters per log line... – Goran Petanjek Sep 03 '18 at 08:10
  • Can u maybe see if the above solution does print the whole soap xml? So that we can exclude that it is logback maybe? – Willem Evertse Sep 03 '18 at 09:13
  • Above solution does not work because of "com.ctc.wstx.exc.WstxIOException exception and the message: >Attempted read on closed stream.". But logging response with: https://stackoverflow.com/questions/12175002/getting-raw-xml-soap-response-on-client-side-using-adb-stubs-created-by-axis2#answer-29781593 works, so I suspect this is not issue with logback. Maybe problem is with commons httpclient, because log category: "httpclient.wire.header" is problematic one... – Goran Petanjek Sep 03 '18 at 09:41
  • Yeah that error you get if there is no response/request to read. But good that we know it isnt logback. – Willem Evertse Sep 03 '18 at 09:59
  • Apparently here lies problem: https://github.com/FasterXML/woodstox/blob/master/src/main/java/com/ctc/wstx/api/ReaderConfig.java, specifically in variable mInputBufferLen which is 4000 :( I suspect there isn't a easy way to change that... – Goran Petanjek Sep 03 '18 at 16:14