LogReader binding

I saw you enabled DEBUG logging already so anything unusual there now?

String LastWarningEvent { channel="logreader:reader:Reader:lastWarningEvent" } working
String LastErrorEvent { channel="logreader:reader:Reader:lastErrorEvent" } working
String LastCustomEvent { channel="logreader:reader:Reader:lastCustomEvent" } working

Number WarningEventsMatched { channel="logreader:reader:Reader:warningEvents" } working
Number ErrorEventsMatched { channel="logreader:reader:Reader:errorEvents" } working
Number CustomEventsMatched { channel="logreader:reader:Reader:customEvents" } working

DateTime LogRotated { channel="logreader:reader:Reader:logRotated" } no entry ( but can take time to appear in the past )

Switch NewWarningEvent { channel="logreader:reader:Reader:newWarningEvent" } no entry
Switch NewErrorEvent { channel="logreader:reader:Reader:newErrorEvent" } no entry
Switch NewLastCustomEvent { channel="logreader:reader:Reader:newCustomEvent" } no entry

the last three are a trigger, a flag for an event, Will check with a rule

Yet to spot anything in debug of significance

logRotated does update only when log really rotates so nothing unusual there. Those last three channels are trigger channels. You do not define them in .items file. They can be used in rules. Look for example.rules section in binding readme to get a hint.

I’d say you’re good to go :wink:

Be nice if the paper ui mentioned the word Trigger :smile:

Best to add persistence to some things ( looking at LogRotated ), a steeper learning curve i think

Is there a way to handle the long strings in BasicUI example the String LastWarningEvent

I guess I could use the triggers in a rule to create my own specific logging

Best to add persistence to some things ( looking at LogRotated ), a steeper learning curve i think

Don’t know why you want to persist any of these channels. The original idea of this binding was to get these parsed log lines to be sent further for example with telegram or mail action. Not to fil your database with errors.

Is there a way to handle the long strings in BasicUI example the String LastWarningEvent

I guess you mean something to chop it shorter to fit in the screen. No nothing usefull really. Maybe you can come up with a few proxy items and rules to shorten the line?

I guess I could use the triggers in a rule to create my own specific logging

Anything is possible but is it going to be usefull in the end. If you want to fiddle around with logging there’s few good tutorials on the forum about modifying log settings to your needs. Just use the search.

Happy hacking!

1 Like

This bindings pull request is now merged and you can soon find it in the SNAPSHOT builds. Good job @pauli_anttila!

/Miika

I can’t figure out, how to use the Error Blacklisting Patterns.
If I want to blacklist e.g.

2018-05-17 11:00:41.815 [ERROR] [org.openhab.io.net.http.HttpUtil    ] - Fatal transport error: java.net.SocketTimeoutException: Read timed out

how do I have to fill in the PaperUI configuration parameters?
Thanks for your help.

To answer my question myself: File based configuration works by just adding the Error. Doing the same over PaperUI doesn’t work.

Can you share things for logreader?
Looking for following two : 1. Custom key word 2. Reading the mossquitto.log (other th
an openhab application log.8

Can you share things for logreader?
Looking for following two : 1. Custom key word 2. Reading the mossquitto.log (other th
an openhab application log.

you have to fill in the binding page for logreader inpaper ui

Thats my thing:

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" ]

I don’t use custom key word and reading other logs (I even don’t know if it is possible).

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