Openhab Error messages to external Management system (SNMP)

I’m looking for a solution where error messages from openhab are being sent to an external Management system, e.g. via SNMP.
Ideally openhab would support a kind of SNMP appender in the log4j logger architecture.

Any thoughts?

best regards
Thomas

this: https://logging.apache.org/log4j/2.x/manual/appenders.html should be more than enough :slight_smile:

Thanks Dim!
I saw this already but wasn’t sure if just adding the appender configuration to org.ops4j.pax.logging.cfg would work (without any modification within the openhab code) ?

I’ll give it a try anyway.

regards
Thomas

Hi Thomas,

Which openHAB version are you using?

The link that I gave you will work for log4j2 (which can be found on OH2.2 +)

In theory, you don’t need any modifications to the openhab code to configure custom destinations for log4j2 (I haven’t tried it… but it should work)

Hi Dim,

this is excellent feedback, much appreciated.
I’m using OH2.2, so as I said I will give it a try, and will report the outcome.

Thanks again!

regards
Thomas

1 Like

It is working!
Let me just briefly post my /var/lib/openhab2/etc/org.ops4j.pax.logging.cfg

(don’t forget to add the appender to root logger parameters )

Root logger

log4j.rootLogger = WARN, email, out, osgi:*
.
.
.
.
.
#SMTP appender
log4j.appender.email=org.apache.log4j.net.SMTPAppender
log4j.appender.email.SMTPHost=xxxxx
log4j.appender.email.SMTPPort=25
log4j.appender.email.SMTPUsername=yyyyy
log4j.appender.email.SMTPPassword=yyyyyy
log4j.appender.email.From=zzzz@hhh.net
log4j.appender.email.To=ffffff@hhh.net
log4j.appender.email.Subject=openhab Log of messages
log4j.appender.email.BufferSize=1
log4j.appender.email.layout=org.apache.log4j.PatternLayout
log4j.appender.email.layout.ConversionPattern=%m

glad you got it working! :slight_smile:

…careful with that Buffer… you may spam your SMTP host :stuck_out_tongue:

(on the other hand… There should be very few WARN level messages on a stable OH2 deployment, so it should be ok)

by the way: log4j or log4j2 ?