Disable INFO level logging for Spring boot websocket MessageBroker logs

Viewed 5770

I have a spring boot application with Websocket enabled wit SockJs. All works nice but it keeps logging below message in the console.

2017-09-19 11:04:48.164  INFO 8856 --- [MessageBroker-4] o.s.w.s.c.WebSocketMessageBrokerStats    : WebSocketSession[1 current WS(1)-HttpStream(0)-HttpPoll(0), 3 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(3)-CONNECTED(3)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 45], outboundChannelpool size = 0, active threads = 0, queued tasks = 0, completed tasks = 22], sockJsScheduler[pool size = 4, active threads = 1, queued tasks = 2, completed tasks = 65909]

What is the significance of the log and how can I disable only these type of logging?

2 Answers

I would like to improve this answer based on the comment of @Dino, because it is true that this solution doesn't show the logs but it doesn't disable the task and doesn't prevent unnecessary resource usage.

To prevent unnecessary resource usage use the following implementation:

@Configuration
public class WebSocketLoggingConfigurer {

    @Autowired
    private WebSocketMessageBrokerStats webSocketMessageBrokerStats;

    @PostConstruct
    public void init() {
        webSocketMessageBrokerStats.setLoggingPeriod(0);
    }

}

Now it is not necessary to modify the log level using application.properties.

Related