Write Domoticz logfile to Synology Log Center

From Domoticz
Jump to navigation Jump to search

Configuration Synology DSM 5.2

  1. - Log on to Synology DSM 5.2 and open Log Center
  2. - Go to Storage Settings, Destination and choose a location to save the file for logging.
  3. - Apply
  4. - Go to Log Receiving, mark BSD format settings and use TCP and Port 514 or choose your own port number.
  5. - Apply

Configuration Raspberry

log on with Putty to the Rapsberry

Fist we need the change the location of the logfile from Domoticz. For this example we use /var/log/domoticz.log

cd /etc/init.d/

sudo nano domoticz.sh

Change the line witch starts with DAEMON_ARGS line this:

DAEMON_ARGS="-daemon -www 8080 -sslwww 443 -log /var/log/domoticz.log

note: remove the # from the line you want to use!!''

Restart Domoticz so the log file will be created in /var/log,

sudo service domoticz.sh restart

Installation syslog-ng

Log in as Root user

sudo –i

Install syslog-ng

sudo apt-get install syslog-ng

Open file syslog-ng.conf

nano /etc/syslog-ng/syslog-ng.conf

Add to # Sources

source s_domoticz { file("/var/log/domoticz.log"); };

Add to # Destinations and change the IP Synology and Portnr Log Center to your NAS.

destination d_centralsyslog { tcp( "IP Synology" port(Portnr Log Center) ); };

Add to # Log paths

log { source(s_domoticz); destination(d_centralsyslog); };

Restart syslog-ng

sudo service syslog-ng restart

Synology Log Center

  1. - Open Synology Log Center
  2. - Click on Log Search
  3. - Click on From Other Servers
  4. - Refresh screen with round Arrow (down right side of the screen)

If all went well you can now see the log file from Domoticz in Synology Log Center.

Logrotate

When you start using Synology Log Center it is best to also use logrotate. The Domoticz lofile grows very fast and logrotate will delete the log file at certain moments.

Create a file called domoticz in /etc/logrotate.d

sudo nano /etc/logrotate.d/domoticz

Put inside this file

/var/log/domoticz.log 
{ 
rotate 4 
weekly 
missingok 
notifempty 
delaycompress 
compress 
postrotate 
if [ -f /var/run/domoticz.pid ]; then 
/etc/init.d/domoticz.sh restart > /dev/null 
fi 
endscript 
}

Your Done.