Mqtt broker: timestamp format

Hello,

I use the mqtt-broker addon in my hass docker installation
On the GUI, the mqtt log looks something like

[12:41:55] INFO: Setting up user owntracks
[12:41:55] INFO: Setting up user ems-esp
[12:41:56] INFO: Setting up user mqtt-explorer
[12:41:56] INFO: SSL is not enabled
[cont-init.d] mosquitto.sh: exited 0.
[cont-init.d] nginx.sh: executing... 
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[12:41:56] INFO: Starting NGINX for authentication handling...
[12:41:57] INFO: Starting mosquitto MQTT broker...
1623580917: mosquitto version 1.6.12 starting
1623580917: |-- *** auth-plug: startup
[12:41:58] INFO: Successfully send discovery information to Home Assistant.
[12:41:58] INFO: Successfully send service information to the Supervisor.
1623580917: Config loaded from /etc/mosquitto/mosquitto.conf.
1623580917: Loading plugin: /usr/share/mosquitto/auth-plug.so
1623580917:  ├── Username/password checking enabled.
1623580917:  ├── TLS-PSK checking enabled.
1623580917:  └── Extended authentication not enabled.
1623580917: Opening ipv4 listen socket on port 1883.
1623580917: Opening ipv6 listen socket on port 1883.
1623580917: Opening websockets listen socket on port 1884.
1623580917: Warning: Mosquitto should not be run as root/administrator.
1623580917: mosquitto version 1.6.12 running
1623580917: New connection from 127.0.0.1 on port 1883.
1623580917: Socket error on client <unknown>, disconnecting.
1623580918: New connection from 192.168.4.17 on port 1883.
1623580918: New client connected from 192.168.4.17 as mqttjs_a16e6b31 (p2, c1, k60, u'zigbee2mqtt-17').
1623580918: New connection from 192.168.3.116 on port 1883.
1623580918: New client connected from 192.168.3.116 as ems-esp (p2, c1, k60, u'ems-esp').
1623580926: New connection from 192.168.4.86 on port 1883.
1623580926: New client connected from 192.168.4.86 as 9a7d613c93984fe0bb2f8d68603e441e (p2, c1, k15, u'zigbee2mqttassistant-86').

In the beginning, the logging is with a readable timestamp.
Further on, it’s a number, probably also a timestamp but in another format.

Is it possible to reconfigure the addon, so that logging will alway appear in (ISO)time format?

kind regards,
B

I believe if you add a file named “mosquitto.conf” to your HASS box under “/share/mosquitto/”
With the file containing:

log_timestamp true
log_timestamp_format %Y-%m-%dT%H:%M:%S

Your log will look like this:

2021-06-11T17:37:01: Saving in-memory database to /data/mosquitto.db.
2021-06-11T18:07:02: Saving in-memory database to /data/mosquitto.db.
2021-06-11T18:37:03: Saving in-memory database to /data/mosquitto.db.
2021-06-11T19:07:04: Saving in-memory database to /data/mosquitto.db.
2021-06-11T19:37:05: Saving in-memory database to /data/mosquitto.db.
2021-06-11T20:07:06: Saving in-memory database to /data/mosquitto.db.
2021-06-11T20:37:07: Saving in-memory database to /data/mosquitto.db.
2021-06-11T21:07:08: Saving in-memory database to /data/mosquitto.db.
2021-06-11T21:37:09: Saving in-memory database to /data/mosquitto.db.
2021-06-11T22:07:10: Saving in-memory database to /data/mosquitto.db.
2021-06-11T22:37:11: Saving in-memory database to /data/mosquitto.db.
2021-06-11T23:07:12: Saving in-memory database to /data/mosquitto.db.
2021-06-11T23:37:13: Saving in-memory database to /data/mosquitto.db.
2021-06-12T00:07:14: Saving in-memory database to /data/mosquitto.db.

Hope it helps.

Edit:
Found the original post where I found out about it: How to modify mosquitto.conf?

1 Like

Works like a charm. Thanx!