LogReader binding

Thanks
Binding documentations says if you specify the log file path then openhab will read that log .
@ custom channel : I want alert on specific error for Alexa control binding : logging failular. Typically every alternate day it is asking me to login with captcha.

Thanks Syn.

Hi Chode
Yes I read it but my bad to found it little confusing to me .
as Syn shared let me try these options

  1. ability to notify for specific event
    logreader:reader:openhablog[ refreshRate=1000, warningPatterns=“WARN+”, warningBlacklistingPatterns=“Warning to block|another warning to block”, errorPatterns=“ERROR+”, errorBlacklistingPatterns=“Error to block|another error to block”,customPatterns=“WARN+”, customBlacklistingPatterns=“Warning to block|another warning to block”, ]
    2.ability to specify error /warn / event for another applications
    logreader:reader:mqttlog[ filePath=/var/log/mosquitto/mosquitto.log,refreshRate=1000, warningPatterns=“WARN+”, warningBlacklistingPatterns=“Warning to block|another warning to block”, errorPatterns=“ERROR+”, errorBlacklistingPatterns=“Error to block|another error to block”,customPatterns=“WARN+”, customBlacklistingPatterns=“Warning to block|another warning to block”, ]
    What I am not sure about this is how to mention the filepath if Log file is @ local host or different server

Case 1 is working
Case 2 It says can not find path{} any suggestion to custom path setting in text configuration
thing definition for case 2
logreader:reader:mosquittolog[ filePath=/var/log/mosquitto/mosquitto.log,refreshRate=1000, warningPatterns=“connected+”, warningBlacklistingPatterns=“Warning to block|another warning to block”, errorPatterns=“error+”, errorBlacklistingPatterns=“Error to block|another error to block”,customPatterns=“openhabpi+”, customBlacklistingPatterns=“Warning to block|another warning to block”]

Kindly suggest how to define the path

1 Like

a) filePath is a string configuration parameter, so value should be between apostrophes.

filePath="/var/log/mosquitto/mosquitto.log"

b) openHAB should have access rights to read the file. Most probably the user with which rights the openHAB is being run, doesn’t have access rights to /var/log/mosquitto directory.

Thanks Pauli,

Tried following entry thing post modifying the mosquitto.log permission to same as openhab.log (-rw-rw-r-- 1 )

logreader:reader:mosquittolog[ filePath="/var/log/mosquitto/mosquitto.log",refreshRate=1000, warningPatterns=“connected+”, warningBlacklistingPatterns=“Warning to block|another warning to block”, errorPatterns=“error”, errorBlacklistingPatterns=“Error to block|another error to block”,customPatterns=“openhabpi+”, customBlacklistingPatterns=“Warning to block|another warning to block”]

error in log file : 2018-06-15 17:36:42.829 [hingStatusInfoChangedEvent] - ‘logreader:reader:mosquittolog’ changed from OFFLINE (COMMUNICATION_ERROR): Log file ‘{}’ does not exist to ONLINE

steps Done @ file permissions :
pi@raspberrypi:/var/log $ ls -l openhab2/openhab.log
-rw-rw-r-- 1 openhab pi 12079394 Jun 15 17:10 openhab2/openhab.log – Openhab.log permission
pi@raspberrypi:/var/log/mosquitto $ ls -l mosquitto.log
-rw------- 1 pi www-data 32500 Jun 15 17:03 mosquitto.log
pi@raspberrypi:/var/log/mosquitto $ chmod 664 mosquitto.log
pi@raspberrypi:/var/log/mosquitto $ chown pi:openhab mosquitto.log
pi@raspberrypi:/var/log/mosquitto $ ls -l mosquitto.log
-rw-rw-r-- 1 pi openhab 32500 Jun 15 17:03 mosquitto.log
pi@raspberrypi:/var/log/mosquitto $ chown openhab:pi mosquitto.log
chown: changing ownership of ‘mosquitto.log’: Operation not permitted
pi@raspberrypi:/var/log/mosquitto $ sudo chown openhab:pi mosquitto.log
pi@raspberrypi:/var/log/mosquitto $ ls -l mosquitto.log
-rw-rw-r-- 1 openhab pi 32500 Jun 15 17:03 mosquitto.log – mosquitto.log permission

I did same with mosquitto directory permission but no luck .

You probably don’t want to change the owner of the mosquitto.log file as mosquitto is not able to write data to file anymore.

It should be enough to add read access to others (sudo chmod o+r /var/log/mosquitto/mosquitto.log).

I just tested logreader with mosquito.log file and it worked fine.

logreader:reader:mosquittolog[ filePath="/var/log/mosquitto/mosquitto.log", refreshRate=1000, customPatterns=".*+" ]

String  mosquittoTest { channel="logreader:reader:mosquittolog:lastCustomEvent" }

For testing purposes I also gave write access to log file to all

sudo chmod 666 /var/log/mosquitto/mosquitto.log

and then echoed some data to file

sudo echo testdata >>  /var/log/mosquitto/mosquitto.log

16:43:35.424 [INFO ] [smarthome.event.ItemStateChangedEvent] - mosquittoTest changed from NULL to testdata

Looks like i broke my long running mosquitto broker . Let me fix and try above .

Its working great

I try alot to regex the lastWarningEvent to only the message but I’m not able to fing on google how to make openhab rule to do it…

I do not want the date and hour… because I want the say() command to only say my warnLog and my item to reflect only the messages

I’v try hard at regex:
(?<=- ).*

Here validator bin
Is there a way to get only the message from log?