Using influxdb as logappender - need assistance

Hi,

i try to use influxdb as logging appender.
I have found this appender GitHub - chicobento/influxdb-log4j2: A Log4j 2 appender for InfluxDB and try to use it with openhab.
Regarding the documentation i found:

I tried the following:

  1. Placing the influxdb-log4j2-0.1-SNAPSHOT.jar and log4j-nosql-2.9.1.jar in the /usr/share/openhab2/addons/ dir
  2. adding a EXTRA_JAVA_OPTS parameter -Dlog4j.plugin.packages=/usr/share/openhab2/addons/influxdb-log4j2-0.1-SNAPSHOT.jar,/usr/share/openhab2/addons/log4j-nosql-2.9.1.jar
  3. added following section to the \openhab2-userdata\etc\org.ops4j.pax.logging.cfg
# influxdb  appender
log4j2.appender.nosql.type = NoSql 
log4j2.appender.nosql.name = INFLUX
log4j2.appender.nosql.nosqlprovider.type = InfluxDb 
log4j2.appender.nosql.nosqlprovider.databaseName = openhabLogging
log4j2.appender.nosql.nosqlprovider.seriesName = openhabLog
log4j2.appender.nosql.nosqlprovider.url = http://localhost:8086
log4j2.appender.nosql.nosqlprovider.username = 
log4j2.appender.nosql.nosqlprovider.password = 

But i get still this Error on startup:

org.ops4j.pax.logging.pax-logging-api [log4j2] ERROR : Unable to locate plugin type for NoSql Ignored FQCN: org.apache.logging.log4j.spi.AbstractLogger
org.ops4j.pax.logging.pax-logging-api [log4j2] ERROR : Unable to locate plugin for InfluxDb Ignored FQCN: org.apache.logging.log4j.spi.AbstractLogger
org.ops4j.pax.logging.pax-logging-api [log4j2] ERROR : Unable to locate plugin for NoSql Ignored FQCN: org.apache.logging.log4j.spi.AbstractLogger
org.ops4j.pax.logging.pax-logging-api [log4j2] ERROR : Unable to invoke factory method in class org.apache.logging.log4j.core.config.AppendersPlugin for element Appenders: java.lang.NullPointerException Ignored FQCN: org.apache.logging.log4j.spi.AbstractLogger
java.lang.NullPointerException
at org.apache.logging.log4j.core.config.plugins.visitors.PluginElementVisitor.visit(PluginElementVisitor.java:52)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.generateParameters(PluginBuilder.java:258)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:579)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:285)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.configureLog4J2(PaxLoggingServiceImpl.java:409)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:272)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImpl.java:569)
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1118)
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1074)
at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:138)
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:105)
at java.lang.Thread.run(Thread.java:748)

Any idea what i do wrong?

Sorry, no solution, only an observation: I noticed that influxdb-log4j2 has not been updated for 4 years and the last InfluxDB version it was adapted to was 0.9. What InfluxDB version are you using? Same question for the log4j version supported by this old plugin…

Thank you for your hint :slight_smile:

I use the newest influx 1.7 and the log4j2 should be the version openhab uses, i think.

I guess the main issue currently is, that the plugins are not loaded correctly.
What i don’t know exactly how to specify the -Dlog4j.plugin.packages= an how java is loading JAR files.

I am using logparser in telegraf + influxDB

1 Like

Cool, would you share your configuration?

I limited myself to a minimum of levels. you can infuse them to your taste with the Grok designer.
Sorry for my English. :grinning:

[[inputs.logparser]]
files = ["/var/log/openhab2/openhab.log"]
from_beginning = false
watch_method = “inotify”
[inputs.logparser.grok]
patterns = [’’’%{TIMESTAMP_ISO8601:timestamp} [%{LOGLEVEL:level:tag} ] [%{GREEDYDATA:class:tag}]%{GREEDYDATA:msg}’’’]

Understood. My message was that it is likely that this old plugin does not support the current log4j and InfluxDB versions.

Seems like a better alternative, indeed.