Logs topics Mosquitto under Docker

Hello,
im running Mosqitto under Docker by using docker-compose file on a NAS-System. The MQTT-Broker works in a small Smart-Home-Environment with a few temperature-sensors.

Now I’m trying to expose the topics of these sensors by the Mosquitto logs, but I don’t know where to find. I use a logs-file, but it seems, that find the specific topics in that.

I use the following conf-settings:

persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
log_dest stdout
log_dest topic
log_type all
listener 1883

I would be glad if someone could help me where to find the logs.
Do I have to enter in the mosquitto-container by terminal? Could you explain me how to achieve that?

Thanks a lot for your help in advance an best regards - Daniel

Hi Daniel,

If I understand what you’re asking, I’m afraid it isn’t possible within mosquitto directly. I think you want to print the messages received on your topics to /mosquitto/log/mosquitto.log, is that right?

The log_dest topic config option is used to send the output of the mosquitto logs to an MQTT topic rather than the other way round.

You could log the topics you are interested in by running a separate client, for example mosquitto_sub -t <your-topic> -v > /your/log/file.

When you start the container you can specify that local directories are mapped into the container:

docker run <your options> -v <absolute-path-to-log-directory>:/mosquitto/log eclipse-mosquitto

That means you can then view the logs on your local machine without having to enter the container.

Regards,

Roger

Hello Roger,
thanks for your quick response. Im a verry newbie in MQTT-Stuff and I’m just doing my first steps. So sorry for my missunderstanding. :wink: I wana try to explain, what I’m searching for.:

I already store the logs in a log file.
I have a small Smart-Home-Setup, with three temperature sonsors, which use mosquitto as MQTT-Broker.
By using node-RED i wana try to store the MQTT-Data from Mosqitto to an influx Database. To achieve this, I need to know the name of the certain topics, which are used by the temperature sensors.
Acutally I do not know how the topic is called, which node-RED should look for.

Maybe you or someone else could help me to solve the beginner-question. :wink:

I found a tutorial that shows how to find the topics on a raspberry-pi.
But I don’t know how to do this by using docker.

Thanks and Regardst - Daniel

Right, I understand now. In this case I would use a client that subscribes to the # topic, which means it will see everything being published by any client, and so you can find the topics you are interested in.

One way to do this is with mosquitto_sub:

mosquitto_sub -h <ip of your broker> -t '#' -v

Or

docker run -it eclipse-mosquitto mosquitto_sub -h <ip of your broker> -t '#' -v

Or you could use a graphical client like MQTT Explorer: http://mqtt-explorer.com/

Regards,

Roger

Hi, thanks a lot for your advice.
I tried the graphical client and especially in the beginning this helped me a lot to understand in a visual manner how MQTT works. I could find out the topics, which I was searching for. In my case my little temperature-sensors does not even use single-value-topics, but also multiple-value as json. So I followed again this tutorial to understand how to deal with the data in Node-RED. On this way I’m now able to write the data in my influxDB. Thanks for your help.
Best Regards - Daniel

1 Like