GH-340: Fix logging for WebSocket server side

Fixes https://github.com/spring-projects/spring-integration-samples/issues/340

The `LoggingHandler` uses a `org.springframework.integration.handler` category by default.
So, the `info` provided for the `loggingChannelAdapter` service activator does not
have any effects because `logback.xml` has an `ERROR` for the
`org.springframework.integration` category

* Use dedicated `wsLog` category in the `LoggingHandler` bean definition
to print a server message published to the subscribed web socket clients
This commit is contained in:
abilan
2023-01-03 11:55:36 -05:00
parent 5dd165b349
commit 4eef6ee08b

View File

@@ -128,6 +128,7 @@ public class Application {
@ServiceActivator(inputChannel = "sendTimeChannel")
public MessageHandler loggingChannelAdapter() {
LoggingHandler loggingHandler = new LoggingHandler("info");
loggingHandler.setLoggerName("wsLog");
loggingHandler.setLogExpressionString(
"'The time ' + payload + ' has been sent to the WebSocketSession ' + headers.simpSessionId");
return loggingHandler;