...
Option | Default | Description |
---|---|---|
formatter |
| Sets the Trace Formatter to use. Will default use |
enabled | true | Flag to enable or disable this tracer |
logLevel | | The logging level to use: FATAL, ERROR, WARN, INFO, DEBUG, TRACE |
logName |
| The log name to use. Will default use |
traceFilter | null | An exchange Predicate to filter the tracing. |
traceInterceptors | false | Flag to enable or disable tracing of interceptors |
traceExceptions | true | Flag to enable or disable tracing of thrown exception during processing of the exchange |
destination | null | Camel 2.0: Optional Destination to route TraceEvent exchange containing TraceEventMessage with details about the trace. Can be used for custom processing to store traces in database using JPA. |
Formatting
The tracer formats the execution of exchanges to log lines. They are logged at INFO level in the log category: org.apache.camel.processor.interceptor.TraceInterceptor
.
The tracer uses by default TraceFormatter
to format the log line.
...
Option | Default | Description |
---|---|---|
breadCrumbLength | 0 | Camel 1.5.1: Fixed length of the bread crumb. 0 = no fixed length. Setting a value to eg 80 e.g. 80 allows the tracer logs to be aligned for easier reading. |
nodeLength | 0 | Camel 2.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. |
showBreadCrumb | true | Outputs the unique unit of work for the exchange. To be used for correlation so you can identify the same exchange. |
showNode | true | The destination node. |
showExchangeId | false | To output the unique exchange id. Currently the breadcrumb is sufficient. |
showShortExchangeId | false | Camel 1.5.1: To output the unique exchange id in short form, without the hostname. |
showProperties | true | Output the exchange properties |
showHeaders | true | Output the in message headers |
showBodyType | true | Output the in body Java type |
showBody | true | Output the in body |
showOutBodyType | false | Camel 2.0: Output the out body Java type |
showOutBody | false | Camel 2.0: Output the out body |
showExchangePattern | true | Camel 1.5: Output the exchange pattern |
showException | true | Camel 1.5: Output the exception if the exchange has failed |
...
Wiki Markup |
---|
{snippet:id=tracingOutExchanges|title=Java DSL|lang=xmljava|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorWithOutBodyTraceTest.java} |
...
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 Custom Formatter
Avaiable as of Camel 2.0
You can now implement your own org.apache.camel.processor.interceptor.TraceFormatter
to be used for logging trace messages to the log.
The sample below shows how to configure a Tracer from Java DSL using custom formatter:
Wiki Markup |
---|
{snippet:id=e1|lang=java|url=activemq/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=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceFormatterTest.java} |