Set up Domoticz to syslog

From Domoticz
Jump to: navigation, search


In this page, we will describe how to make Domoticz log to syslog. In this case it is set up to use rsyslog. Other syslog implementation should be very similar.

The purpose of this is to be able to send the Domoticz log to other systems for remote logging, be able to separate the Domoticz log into separate syslog facilities/logfiles and/or consolidate the logs from several Domoticz instances on a shared loghost.


For this setup, you will need to use a version of Domoticz that supports selecting the syslog facility to be used. The help text indicating this is supported is:

$ ./domoticz -h 
2016-03-09 20:18:17.747  Domoticz V3.4933 (c)2012-2016 GizMoCuz
2016-03-09 20:18:17.894  Build Hash: e404b11, Date: 2016-03-09 17:30:00
. (lines deleted)
-syslog [user|daemon|local0 .. local7] (use syslog as log output, defaults to facility 'user')

Versions before this will log to syslog faciliity user (a.k.a. LOG_USER), which is still the default if no argument is provided

Syslog facilities are message poperties that can be used in your /etc/rsyslog.conf file to determine how to further route the messages into files and/or relay messages to remote syslog servers.

Setup procedure

Change the DAEMON_ARGS

You will need to edit /etc/init.d/ and make the DAEMON_ARGS include at least:

 DAEMON_ARGS="-loglevel normal -syslog local1 -daemon -www .........."

Where the Domoticz log level and syslog facility is your choice.

Set up a dedicated syslog logfile for Domoticz

This an optional step, You may want to supplement the above local1 log facility with a separate syslog file. For rsyslog, that can be set up as follows in /etc/rsyslog.conf                       -/var/log/user.log                     -/var/log/local0.log                     -/var/log/local1.log                     -/var/log/local2.log

If you want to send the same to a remote system, use an ip address or hostname, or more commonly a loghost alias, as follows:                       @@loghost                     @loghost                     @loghost                     @

The first entry will log using a TCP connection (more modern syslog implementations), the other will use UDP datagrams (legacy) for the message protocol transport

Restart services

You can now restart Domoticz and rsyslog

sudo service rsyslog restart
sudo service restart

Then make sure that the logfiles update:

tail -f /var/log/local1.log

Set up log rotation

If your /var/log filesystem is small, you will want to set up log rotation as well. In Raspian and many other Linux distros, the logrotate utility runs from a daily cron job (ref /etc/cron.daily/logrotate)

A suggested setup can be set up by creating a /etc/logrotate.d/local configuration file containing the following:

       rotate 4
       maxsize 64M
               invoke-rc.d rsyslog rotate > /dev/null

Refer to man logrotate for an explanation of the semantics of this.


Take care if you use a SD card for the /var/log files. Logging a lot will likely make the SD card fail over time.

Consider to use tmpfs or look into Setting up overlayFS on Raspberry Pi instead