it is hard to debug issues when you constantly have to convert the timestamp to a readable format.
should be formatted with yyyy-MM-dd HH:mm:ss+Z (java equiv) using os time zone.
Or, you should use syslog if you need/want customizations. long dates take up more already limited horizontal space. (I appreciate the idea, just putting out the opposites, for everyone who wants one way, others want the reverse)
"Or, you should use syslog"
.. thanks for the suggestion, how do I get mosquitto logging to syslog with a timestamp?
That's (unfortunately) entirely dependent on what syslog daemon you're using, and how it's configured. But it's pretty much exactly what syslog is for. rsyslog and syslog-ng are both commonly available, you can probably make all sorts of timestamp formatting changes in plain old syslogd itself too.
In mosquitto.conf you could do:
log_dest syslog
log_facility 0
log_timestamp false
And then in your syslog daemon configure the local0 facility to log as you want. In rsyslog this would be something like
local0.* -/var/log/mosquitto.log
This hasn't seen any updates in a while, if you still think there is an issue here please reopen and add more information.
I get the decision but wouldn't it be fairly easy and harmless to have a log_timeformat with maybe human and unix and have it default to unix if not defined?
Going via syslog is a solution but needs a fair bit of setup everytime you setup a broker, if it were an option I could just drop in my standard config an be done with it.
+1
@ralight should we open a new issue? No one can re-open this issue other than contributors and the op.
What is the point of having an option to add a timestamp in the logs that is only machine readable. For humans it is useless IMHO. Would a pull request make a chance of being approved?
+1 for human-readable timestamps
tail -f /var/log/mosquitto/mosquitto.log | perl -pe 's/(\d+)/localtime($1)/e'
I just found out that this has been implemented in https://github.com/eclipse/mosquitto/commit/1a234323a3912fda3c1d90743d903beb737df862:
log_dest file /mosquitto/log/mosquitto.log
log_timestamp true
log_timestamp_format %Y-%m-%dT%H:%M:%S
1561035855: mosquitto version 1.6.3 terminating
1561035855: Saving in-memory database to /mosquitto/data/mosquitto.db.
2019-06-20T15:04:22: mosquitto version 1.6.3 starting
Hi
I do have an error when using:
log_timestamp_format %Y-%m-%dT%H:%M:%S
Error: Unknown configuration variable "log_timestamp_format".
Error found at /etc/mosquitto/mosquitto.conf:16.
running: mosquitto is already the newest version (1.4.15-2ubuntu0.18.04.3).
running: mosquitto is already the newest version (1.4.15-2ubuntu0.18.04.3).
Hi @riker65 , I'm pretty sure that's not the newest version :) 1.4.x < 1.6.x
@riker65
You need to add this source
deb http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
It will give you this policy at the moment
mosquitto:
Installed: 1.6.3-0mosquitto1~bionic1
Candidate: 1.6.3-0mosquitto1~bionic1
Version table:
* 1.6.3-0mosquitto1~bionic1 500
500 http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic/main amd64 Packages
100 /var/lib/dpkg/status
1.4.15-2ubuntu0.18.04.3 500
500 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages
500 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages
1.4.15-2 500
500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
Most helpful comment
tail -f /var/log/mosquitto/mosquitto.log | perl -pe 's/(\d+)/localtime($1)/e'