Search code examples
javaspringloggingspring-integrationspring-integration-dsl

Logging in spring integration java DSL


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


Solution

  • 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(...)