我有一个支持Websocket的spring引导应用程序,它支持SockJs。所有这些都很好,但是它一直记录在控制台中的消息下面。
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]日志的意义是什么,我如何才能禁用这些类型的日志记录?
发布于 2017-09-19 05:49:45
尝试在application.properties中使用以下配置
logging.level.org.springframework.web.socket.config.WebSocketMessageBrokerStats = ERROR这将升级此特定类的日志。
发布于 2022-01-06 00:10:38
我想根据@Dino的注释来改进this answer,因为这个解决方案确实没有显示日志,但它没有禁用任务,也没有防止不必要的资源使用。
为了防止不必要的资源使用,请使用以下实现:
@Configuration
public class WebSocketLoggingConfigurer {
@Autowired
private WebSocketMessageBrokerStats webSocketMessageBrokerStats;
@PostConstruct
public void init() {
webSocketMessageBrokerStats.setLoggingPeriod(0);
}
}现在,没有必要使用application.properties修改日志级别。
https://stackoverflow.com/questions/46292669
复制相似问题