Mosquitto 调试级别日志 - 如何保留除 PINGREQ/PINGRESP 之外的所有条目

物联网 蚊子
2021-06-22 07:23:49

我在这里讨论如何避免在日志中 ping 消息。通过更改中的log_type(s),mosquitto.conf我发现 ping 报告在DEBUG LEVEL. 我会在 conf 中评论这个日志类型以避免日志中的 ping,但遗憾的是PUBLISH条目在相同的日志级别下,它们都与我相关。所以,我想知道是否有任何方法可以避免只记录 ping。

这是我的mosquitto.conf

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto.pid

#persistence false
persistence true
persistence_location /var/lib/mosquitto/

#log_dest file /var/log/mosquitto/mosquitto.log
log_dest syslog

log_type error
log_type warning
log_type notice
log_type information
log_type debug
log_type subscribe
log_type unsubscribe
log_type websockets
#log_type all

connection_messages true
log_timestamp true

include_dir /etc/mosquitto/conf.d
2个回答

不,必须编辑代码以从 ping 处理代码中删除日志语句并重新编译代理。

我和你有同样的需求,所以我修改了mosquitto v1.5.3源代码,并log_typemosquitto.conf

log_type ping

来源在 Git Hub 上