简体   繁体   中英

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?

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?

Reference Link : 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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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