How to logging?

Sure. This is a start script I use with svrun on one of my machines;

#!/bin/sh

export HOME=/home/jb
export STNORESTART=1
setuidgid jb /home/jb/bin/syncthing 2>&1 | logger -t syncthing

When this runs, log output gets sent to regular syslog and can be handled by whatever syslog mechanisms you have in place.

jb@syncer:~$ sudo tail -f /var/log/syslog
May 21 14:06:15 syncer syncthing: [LGFPD] 14:06:15 INFO: syncthing v0.8.7-18-ge9eacfa (go1.2.2 linux-amd64) jb@jborg-mbp 2014-05-19 22:59:19 UTC
May 21 14:06:15 syncer syncthing: [LGFPD] 14:06:15 INFO: My ID: LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q
May 21 14:06:15 syncer syncthing: [LGFPD] 14:06:15 INFO: Starting web GUI on http://0.0.0.0:8080/
May 21 14:06:15 syncer syncthing: [LGFPD] 14:06:15 INFO: Populating repository index
May 21 14:06:21 syncer syncthing: [LGFPD] 14:06:21 INFO: No UPnP IGD device found, no port mapping created (read udp4 0.0.0.0:46581: i/o timeout)
May 21 14:06:21 syncer syncthing: [LGFPD] 14:06:21 INFO: Sending local discovery announcements

We get a double timestamp, one from syncthing and one from syslog. Could have a flag to disable that in case the log data is timestamped externally but I haven’t been sufficiently annoyed by it yet.

2 Likes