简体   繁体   English

MQTT Broker-Mosquitto消息记录

[英]MQTT Broker - Mosquitto Message Logging

Is it possible to log MQTT Broker Mosquitto events such as messages published to all channels, subscriptions, client connections/disconnections and errors to a log file with a time stamp and then have program insert this into a database either SQL in encrypted form? 是否可以将MQTT Broker Mosquitto事件(例如发布到所有通道的消息,订阅,客户端连接/断开连接和错误以及错误)记录到带有时间戳的日志文件中,然后让程序以加密形式将其插入SQL或SQL中?

If so, how could this be achieved? 如果是这样,如何实现呢?

What I have tried? 我尝试了什么?

I have subscribed to the topic $SYS/broker/# ,able to get only connection logs,My query here is how can i get what message is sent and received from broker? 我已经订阅了主题$ SYS / broker /# ,该主题仅能获取连接日志,我的查询是如何获取代理发送和接收的消息?

Reference Link : http://www.steves-internet-guide.com/mosquitto-logging/ 参考链接: http : //www.steves-internet-guide.com/mosquitto-logging/

You can add all or a subset of the following entries to the mosquitto.conf file to enable various logging levels and add a timestamp: 您可以将以下条目的全部或子集添加到mosquitto.conf文件中,以启用各种日志记录级别并添加时间戳:

log_dest stdout
log_type error
log_type warning
log_type notice
log_type information
connection_messages true
log_timestamp true
log_timestamp_format [%H:%M:%S] 

This will redirect all Mosquitto logging to stdout , which you can then either pipe into a custom program that ingests it and persists to a database or redirect the output to a file and later process it. 这会将所有Mosquitto日志记录重定向到stdout ,然后您可以通过管道将其导入到一个自定义程序中,该程序将其提取并持久保存到数据库中,或者将输出重定向到文件中,然后对其进行处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM