Log Component
The log: component logs message exchanges to the underlying logging mechanism.
URI format
log:loggingCategory[?level=loggingLevel][options]
Where loggingCategory is the name of the logging category to use and loggingLevel is the logging level such as DEBUG, INFO, WARN, ERROR - the default is INFO
By default Camel uses a regular logging that logs every exchange. However Camel also ships with a Throughput logger that is used if the groupSize
option is specified.
Options
Option |
Default |
Type |
Description |
---|---|---|---|
level |
INFO |
String |
Logging level to use. Possible values: FATAL, ERROR, WARN, INFO, DEBUG, TRACE, OFF |
groupSize |
null |
Integer |
An integer that specifies a group size for throughput logging. By default regular logging is used. |
Formatting
The log formats the execution of exchanges to log lines.
The log uses by default LogFormatter
to format the log output.
LogFormatter has the following options:
Option |
Default |
Description |
---|---|---|
showAll |
false |
quick option for turning all options on |
showExchangeId |
false |
To output the unique exchange id |
showProperties |
false |
Output the exchange properties |
showHeaders |
false |
Output the in message headers |
showBodyType |
true |
Output the in body Java type |
showBody |
true |
Output the in body |
showOut |
false |
If the exchange has an out message then its also shown |
showException |
false |
Camel 2.0: If the exchange has an exception then the exception message is shown (no stacktrace) |
showCaughtException |
false |
Camel 2.0: If the exchange has a caught exception then the exception message is shown (no stacktrace). A caught exception is stored as a property on the exchange, and for instance a |
showStackTrace |
false |
Camel 2.0: Show also the stacktrace if the exchange has an exception |
multiline |
false |
if enabled then each information is logged on a new line |
maxChars |
|
Camel 2.0: Is used to limit the number of chars logged per line. |
Regular logger sample
In the route below we logs the incoming orders at DEBUG level before the order is processed.
from("activemq:orders").to("log:com.mycompany.order?level=DEBUG").to("bean:processOrder");
And using Spring DSL as the route:
<route> <from uri="activemq:orders"/> <to uri="log:com.mycompany.order?level=DEBUG"/> <to uri="bean:processOrder"/> </route>
Regular logger with formatter sample
In the route below we logs the incoming orders at INFO level before the order is processed.
from("activemq:orders"). to("log:com.mycompany.order?showAll=true&multiline=true").to("bean:processOrder");
Throughput logger sample
In the route below we log the throughput of the incoming orders at DEBUG level grouped by 10 messages.
from("activemq:orders"). to("log:com.mycompany.order?level=DEBUG?groupSize=10").to("bean:processOrder");