From 4eef6ee08bf195b6621dd82b675d7b05aa35ee49 Mon Sep 17 00:00:00 2001 From: abilan Date: Tue, 3 Jan 2023 11:55:36 -0500 Subject: [PATCH] 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 --- .../samples/websocket/standard/server/Application.java | 1 + 1 file changed, 1 insertion(+) diff --git a/basic/web-sockets/src/main/java/org/springframework/integration/samples/websocket/standard/server/Application.java b/basic/web-sockets/src/main/java/org/springframework/integration/samples/websocket/standard/server/Application.java index f5c6e96d..f839cf38 100644 --- a/basic/web-sockets/src/main/java/org/springframework/integration/samples/websocket/standard/server/Application.java +++ b/basic/web-sockets/src/main/java/org/springframework/integration/samples/websocket/standard/server/Application.java @@ -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;