Logging to JSON - maybe missing dependency?

Tags: #<Tag:0x00007efed8c0d838> #<Tag:0x00007efed8c0d6a8> #<Tag:0x00007efed8c0d590>

Hello,
I would like to start logging to ELK and JSON seems to be the easiest format for that.
I found multiple topics how to configure OpenHab to log using JSON format however I can’t get it to work. :slightly_frowning_face:

I am getting this error:

Mar 01 00:42:56 pi systemd[1]: Started openHAB 2 - empowering the smart home.
Mar 01 00:43:03 pi karaf[17540]: org.ops4j.pax.logging.pax-logging-api [log4j2] ERROR : Log4J2 configuration problem: com/fasterxml/jackson/databind/ser/FilterProvider Ignored FQCN: org.apache.logging.log4j.spi.AbstractLogger
Mar 01 00:43:03 pi karaf[17540]: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/FilterProvider
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.layout.JsonLayout.<init>(JsonLayout.java:158)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.layout.JsonLayout.<init>(JsonLayout.java:69)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.layout.JsonLayout$Builder.build(JsonLayout.java:102)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.layout.JsonLayout$Builder.build(JsonLayout.java:77)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:934)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:579)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:285)
Mar 01 00:43:03 pi karaf[17540]:         at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.configureLog4J2(PaxLoggingServiceImpl.java:409)
Mar 01 00:43:03 pi karaf[17540]:         at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:272)
Mar 01 00:43:03 pi karaf[17540]:         at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImpl.java:569)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1118)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1074)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:138)
Mar 01 00:43:03 pi karaf[17540]:         at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:105)
Mar 01 00:43:03 pi karaf[17540]:         at java.lang.Thread.run(Thread.java:748)
Mar 01 00:43:03 pi karaf[17540]: Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ser.FilterProvider cannot be found by org.ops4j.pax.logging.pax-logging-log4j2_1.11.2
Mar 01 00:43:03 pi karaf[17540]:         at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:484)
Mar 01 00:43:03 pi karaf[17540]:         at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395)
Mar 01 00:43:03 pi karaf[17540]:         at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387)
Mar 01 00:43:03 pi karaf[17540]:         at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
Mar 01 00:43:03 pi karaf[17540]:         at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
Mar 01 00:43:03 pi karaf[17540]:         ... 25 more

My org.ops4j.pax.logging.cfg (6.6 KB) is here.
I am running OpenHab 2.5.2-1.

It seems like there is missing dependency for jackson - that is strange as I have JSONPath transformation installed (which I believe is using Jackson).
Any ideas please?

I am still trying to figure this out.
It seems that jackson library needs to be loaded before log4j.

I have tried adding:

mvn\:com.fasterxml.jackson.core/jackson-core/2.9.10 = 5         
mvn\:com.fasterxml.jackson.core/jackson-annotations/2.9.10 = 5  
mvn\:com.fasterxml.jackson.core/jackson-databind/2.9.10 = 5     

To /var/lib/openhab2/etc/startup.properties but it leads to the same error.

I see the same issue on my setup. Once I switch to JSON format, logging no longer works. I am using the current snapshot build #56 of version 2.5.3.

For the record: https://github.com/openhab/openhab-core/issues/1383

Same issue here. OH installed on DietPi VM, fresh install stable 2.5.3 using apt-get. After adding json logging (following this post) the logging stops working.