'mosquitto: log message contents

I am using mosquitto as a MQTT-broker and I while it offers extensive logging functionality I can't find out how to log the actual topic's messages to a file (or even to a tree of files ordered by topic, or even a DB). I see the log_desc topic option but either it doesn't do what I expect it to do or it doesn't work (probably the first).

I know I can just subscribe to a (or all) topics on the same machine from another process and pipe that into a file and I know there is a solution to write the again client fetched data into a DB using python, but I want to know if the broker itself can write the data it channels somewhere, not just the metadata.

In the end I will probably need to write it to a DB anyway, but for now it would be fine to write the data into a tree of files, or even just a big logfile. Can the broker service do that?



Solution 1:[1]

I am also using mosquitto.

First install mosquitto-client.
Then

mosquitto_sub -v -t "topic/name" > mylog.txt

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sa_leinad