9

I'm trying to log exchange body as a string using log4j.

<convertBodyTo id="_convertBodyTo1" type="java.lang.String"/>
<to id="_to1" uri="log:com.javarticles?level=INFO"/>

but it's not logging as string

15:09:05,403 | INFO  | qtp938841692-57  | javarticles                      |
198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | 
Exchange[ExchangePattern: InOut, BodyType: java.lang.String, Body: 
org.apache.cxf.jaxrs.impl.HttpHeadersImpl@52767902]

Do we have to make extra logic to log exchange body? And how do we log http headers?

Nurjan
  • 5,889
  • 5
  • 34
  • 54
tvshajeer
  • 1,299
  • 2
  • 12
  • 26
  • 1
    Seems your body contains a bunch of HTTPHeaders..not sure why you have put them as your body. Those headers exist either as exchange headers or exchange properties. You can access them from there. – Souciance Eqdam Rashti Dec 21 '16 at 12:47

1 Answers1

10

If you only want to log the message body, then use

<log message="${body}"/>

The log endpoint logs a bunch of details by default, you can turn these on|off using the options listed: http://camel.apache.org/log

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65