Logging in spring integration java DSL

NIROB AECE :

I want to print message log in the console and write in a log file. I am trying with logging-channel-adapter, LoggingHandler please give me sample code. Thank you

Gary Russell :

Use one of the .log() operators.

For convenience, to log the message journey through the Spring Integration flow (), a log() operator is presented. Internally, it is represented by the WireTap ChannelInterceptor with a LoggingHandler as its subscriber. It is responsible for logging the incoming message into the next endpoint or the current channel. The following example shows how to use LoggingHandler:

.filter(...)
.log(LoggingHandler.Level.ERROR, "test.category", m -> m.getHeaders().getId())
.route(...)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=395165&siteId=1