How to log when a event is triggered
Moderator: leecollings
-
- Posts: 497
- Joined: Friday 22 May 2015 12:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11083
- Location: Asten NB Nederland
- Contact:
How to log when a event is triggered
Hi all,
I would like to log when an event is triggered over a longer period of time.
Can I write the log to a file on my raspberry?
And if yes, does anybody have an example in LUA script how to do this?
Many thnx in advance for your help
Jan
I would like to log when an event is triggered over a longer period of time.
Can I write the log to a file on my raspberry?
And if yes, does anybody have an example in LUA script how to do this?
Many thnx in advance for your help
Jan
Your mind is like a parachute,
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: How to log when a event is triggered
Don't know about lua, in PHP it's quite easy. I made a function for it:
Example:
//Example:
logwrite('Switch '.$idx.' '.$name.' '.$cmd.' by '.$user.' = '.$reply);
writes something like "2015-12-23 17:33:01.657 Switch 26 TV On by Tobi = OK"
Code: Select all
$LogFile = '/var/log/floorplan.log';
function logwrite($msg,$msg2 = NULL) {
global $LogFile;
$time = microtime(true);
$dFormat = "Y-m-d H:i:s";
$mSecs = $time - floor($time);
$mSecs = substr(number_format($mSecs,3),1);
$fp = fopen($LogFile,"a+");
fwrite($fp, sprintf("%s%s %s %s\r\n", date($dFormat), $mSecs, $msg, $msg2));
fclose($fp);
}
//Example:
logwrite('Switch '.$idx.' '.$name.' '.$cmd.' by '.$user.' = '.$reply);
writes something like "2015-12-23 17:33:01.657 Switch 26 TV On by Tobi = OK"
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: How to log when a event is triggered
Any print() statement output from the lua event scripts is logged in /var/log/domoticz.log (assuming you have that active)
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 497
- Joined: Friday 22 May 2015 12:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11083
- Location: Asten NB Nederland
- Contact:
Re: How to log when a event is triggered
Tnx for your quick reply.
I really don't know anything about PHP but this is exactly what I need.
If anybody knows how to translate this in LUA I would be verry, verry grateful!!
I really don't know anything about PHP but this is exactly what I need.
If anybody knows how to translate this in LUA I would be verry, verry grateful!!
Your mind is like a parachute,
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
-
- Posts: 497
- Joined: Friday 22 May 2015 12:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11083
- Location: Asten NB Nederland
- Contact:
Re: How to log when a event is triggered
How can I make that active Jos?Any print() statement output from the lua event scripts is logged in /var/log/domoticz.log (assuming you have that active)
Jos
Your mind is like a parachute,
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: How to log when a event is triggered
Logfile options are set in /etc/init.d/domoticz.sh (domoticz startup script).
-
- Posts: 497
- Joined: Friday 22 May 2015 12:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11083
- Location: Asten NB Nederland
- Contact:
Re: How to log when a event is triggered
And what do I need to change there?
Your mind is like a parachute,
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
-
- Posts: 10
- Joined: Sunday 13 December 2015 19:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to log when a event is triggered
On domoticz.sh file, will have a line that says:
DAEMON_ARGS="-daemon -www 8080 -sslwww 443"
Replace it by this:
DAEMON_ARGS="-daemon -www 8080 -sslwww 443 -log /tmp/domoticz.txt"
I think it will work well.
DAEMON_ARGS="-daemon -www 8080 -sslwww 443"
Replace it by this:
DAEMON_ARGS="-daemon -www 8080 -sslwww 443 -log /tmp/domoticz.txt"
I think it will work well.
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: How to log when a event is triggered
This is what I have from the standard distribution image:
Jos
Code: Select all
DAEMON_ARGS="-daemon -www 8080 -sslwww 443 -log /var/log/domoticz.log"
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 497
- Joined: Friday 22 May 2015 12:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11083
- Location: Asten NB Nederland
- Contact:
Re: How to log when a event is triggered
Thnx guys,
going to work on it
going to work on it
Your mind is like a parachute,
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
Who is online
Users browsing this forum: No registered users and 1 guest