SLF4J Channel Adapter
The slf4j adapter is a sink that logs the message payload through the SLF4J API.
It is useful for debugging, auditing, and logging intermediate outputs.
Usage as sink
The adapter only writes: a flow that reads from it (fromSource("slf4j://…")) fails when the context starts, saying the endpoint "cannot be used as a source".
.toSink("slf4j://my-logger")
The Slf4jProducer logs the output Exchange payload at INFO level using the logger named after the URL.
Usage in WireTap
The SLF4J adapter is particularly useful as a WireTap destination for audit logging:
.wireTap("audit-tap", "slf4j://audit-logger")
.toSink("kafka://output-topic")
In this case the Exchange is logged by SLF4J while simultaneously being sent to Kafka.
The slf4j adapter is exclusively a sink: it does not support use as a flow source.
|