Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Div
classconfluenceTableSmall

Option

Default

Description

destinationUri

null

Optional destination URI to route TraceEventExchange containing TraceEventMessage with details about the trace. Can be used for custom processing to store traces in database using JPA.

enabled

true

Enable/disable the tracer.

formatter

 

Sets the Trace Formatter to use.

Default: org.apache.camel.processor.interceptor.DefaultTraceFormatter.

jpaTraceEventMessageClassName

null

Camel 2.3: Fully qualified class name for a custom org.apache.camel.processor.interceptor.TraceEventMessage class which contains the traced information.

For example you can use your custom JPA @Entity class to store traced information in a database according to your schema layout.

logLevel

INFO

The logging level to use: FATAL, ERROR, WARN, INFO, DEBUG, TRACEOFF

logName

 

The log name to use.

Default: org.apache.camel.processor.interceptor.TraceInterceptor.

logStackTrace

false

Controls whether the stack trace of a traced exception should be logged. If false only the exception's class and message are logged.

traceFilter

null

An Exchange Predicate to filter the tracing.

traceInterceptors

false

Enable/disable tracing of interceptors.

traceExceptions

true

Flag to enable or Enable/disable tracing of an exception thrown exception during the processing of the an Exchange.

traceHandler

null

Camel 2.3: To use a custom org.apache.camel.processor.interceptor.TraceEventHandler where you can control what happens when a trace event occurs.

traceInterceptorFactory

null

Camel 2.3: To use a custom org.apache.camel.processor.interceptor.TraceInterceptorFactory where you can create the runtime trace instance which does the actual tracing. It should be a Processor instance.

Default: org.apache.camel.processor.interceptor.TraceInterceptor.

traceOutExchanges

false

Flag to enable Enable/disable fine grained tracing with , using a callback, for both IN (before) and OUT (after).

By default only one trace callback is executed.

useJpa

false

To use a JpaTraceEventMessage from camel-jpa component as the TraceEventMessage. This requires that camel-jpa.jar is on the classpath.

...

Div
classconfluenceTableSmall

Option

Default

Description

breadCrumbLength

0

Fixed length of the bread crumb. 

0 = no fixed length.

Setting a value to e.g. 80 allows the tracer logs to be aligned for easier reading.

maxChars

 

Limits the number of chars logged per line.

From Camel 2.9: the default value is 10000.

multilinefalseCamel 2.18: If true each piece of information is logged on a new line.

nodeLength

0

Fixed length of the node. 

0 = no fixed length.

Setting a value to e.g. 40 allows the tracer logs to be aligned for easier reading.

showBody

true

Output the IN body.

showBodyType

true

Output the IN body Java type.

showBreadCrumb

true

Outputs the unique unit of work (UOW) UnitOfWork for the exchange.

To Can be used for correlation so you can identify the same to identify a particular Exchange.

showException

true

Output the exception if the exchange processing of an Exchange has failed.

showExchangeId

false

To output the unique exchange Enable/disable the output of an Exchange's unique id.

Currently the breadcrumb is sufficient.

showExchangePattern

true

Output the Message Exchange Pattern (MEP).

showHeaders

true

Output the IN message headers.

showNode

true

Previous and destination node.

Displayed as: from -> to.

showOutBody

false

Output the OUT (if any) body.

showOutBodyType

false

Output the OUT (if any) body Java type.

showOutHeaders

false

Output the OUT (if any) message headers.

showProperties

false

Output the Exchange's properties.

showRouteId

true

Camel 2.8: output the id of the route.

showShortExchangeId

false

To output the Exchange's unique id in short form, without the hostname.

...

You can configure tracing at a higher granularity as you can configure it on camel context and then override and set it per route as well. For instance you could just enable the tracer for one a particular route.

Code Block
INFO  TraceInterceptor     - ID-davsclaus-local-54403-1246038742624-0-0 >>> from(direct:start) --> MyProcessor     , Pattern:InOnly, Headers:{to=James}, BodyType:String, Body:Hello London
INFO  TraceInterceptor     - ID-davsclaus-local-54403-1246038742624-0-0 >>> MyProcessor --> mock:a                 , Pattern:InOnly, Headers:{to=James}, BodyType:String, Body:Hello London
INFO  TraceInterceptor     - ID-davsclaus-local-54403-1246038742624-0-0 >>> mock:a --> mock:b                      , Pattern:InOnly, Headers:{to=James}, BodyType:String, Body:Hello London
...
INFO  TraceInterceptor     - ID-davsclaus-local-54403-1246038742624-0-1 >>> from(direct:start) --> MyProcessor     , Pattern:InOnly, Headers:{from=Claus}, BodyType:String, Body:This is Copenhagen calling
INFO  TraceInterceptor     - ID-davsclaus-local-54403-1246038742624-0-1 >>> MyProcessor --> mock:a                 , Pattern:InOnly, Headers:{from=Claus}, BodyType:String, Body:This is Copenhagen calling
INFO  TraceInterceptor     - ID-davsclaus-local-54403-1246038742624-0-1 >>> mock:a --> mock:b                      , Pattern:InOnly, Headers:{from=Claus}, BodyType:String, Body:This is Copenhagen calling

...

You can configure the tracer as a Spring bean. Just add a bean with the bean class org.apache.camel.processor.interceptor.Tracer and Camel will use it as the tracer.

Wiki Markup
{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/tracerConfigurationTest.xml}
You can configure the formatting of tracer as a Spring bean. Just add a bean with the the id="traceFormatter" and Camel will lookup this id and use the formatter, as the example below illustratesassociated formatter.

Example:

Wiki Markup
{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/traceFormatterTest.xml}

Enable Tracing of out Messages

You can To trace the messages coming out of processing steps . To enable this, configure the tracer as follows:

Wiki Markup
{snippet:id=tracingOutExchanges|title=Java DSL|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorWithOutBodyTraceTest.java}
or
Wiki Markup
{snippet:id=tracingOutExchanges|title=Spring DSL|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/traceInterceptorWithOutBodyTrace.xml}
Running with With these options , you'll get output similar tothe output will look like:

Code Block
INFO  TraceInterceptor - ID-mojo/59899-1225474989226/2-0 -> transform(body) , Pattern:InOnly , Headers:{to=James} , BodyType:String , Body:Hello London
INFO  TraceInterceptor - transform(body) -> ID-mojo/59899-1225474989226/2-0 , Pattern:InOnly , Headers:{to=James} , BodyType:String , Body:Hello London , OutBodyType:String , OutBody:Hello London

Using a Custom Formatter

You can now implement your own To create a custom formatter create a class that implements the interface org.apache.camel.processor.interceptor.TraceFormatter to be used for logging trace messages to the log..

ExampleThe example below shows how to configure a Tracer from Java DSL using custom formatter:

Wiki Markup
{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceFormatterTest.java}
And here we have our custom logger that implements the TraceFormatter interface where we can construct the log message how we like:
Wiki Markup
{snippet:id=e2|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceFormatterTest.java}

...