I need to log the value of the message header with key "foo_bar" so that the log message looks something like this when the value of that header is "baz":
Value of header foo_bar: baz
How to do this with a wire-tap and logging-channel-adapter?
Use the expression attribute of the logging-channel-adapter and set up the wire-tap and logging-channel-adapter something like this:
<integration:channel id="channel1">
<integration:interceptors>
<integration:wire-tap channel="loggingChannel1"/>
</integration:interceptors>
</integration:channel>
<integration:logging-channel-adapter
id="loggingChannel1"
expression="'Value of header foo_bar: '.concat(headers.foo_bar)"
level="DEBUG"
/>
When using the expression attribute, the root object is the spring integration message. So "headers" in the expression gets you the headers map of the message.