karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Baptiste Onofré ...@nanthrax.net>
Subject Re: Custom Log appender trace with custom distribution!
Date Tue, 09 Apr 2019 11:31:37 GMT
Hi,

It seems the appender loads the DataSource via JNDI.

You have to install the jndi feature which provides the initial context
factory.

Then you have the datasource service available via JNDI name.

Regards
JB

On 09/04/2019 11:53, leonardchicco wrote:
> Hi all, 
>    I have a boring problem when I start karaf using custom logging appender
> Follow the section of my "org.ops4j.pax.logging.cfg"
> 
> ================================================================
> # HSQLDB Appender for connectors logs
> log4j2.rootLogger.appenderRef.DBAppender.ref = DBAppender
> log4j2.appender.jdbc.type = jdbc
> log4j2.appender.jdbc.name = DBAppender
> log4j2.appender.jdbc.tableName = CONNECTORS_LOG
> log4j2.appender.jdbc.c1.type=Column
> log4j2.appender.jdbc.c1.name=EVENT_DATE
> log4j2.appender.jdbc.c1.isEventTimestamp = true
> log4j2.appender.jdbc.c2.type = Column
> log4j2.appender.jdbc.c2.name = LOGGER
> log4j2.appender.jdbc.c2.pattern = %logger
> log4j2.appender.jdbc.c2.isUnicode = false
> log4j2.appender.jdbc.c3.type = Column
> log4j2.appender.jdbc.c3.name = LEVEL
> log4j2.appender.jdbc.c3.pattern = %level
> log4j2.appender.jdbc.c3.isUnicode = false
> log4j2.appender.jdbc.c4.type = Column
> log4j2.appender.jdbc.c4.name = MESSAGE
> log4j2.appender.jdbc.c4.pattern = %message
> log4j2.appender.jdbc.c4.isUnicode = false
> log4j2.appender.jdbc.c5.type = Column
> log4j2.appender.jdbc.c5.name = THROWABLE
> log4j2.appender.jdbc.c5.pattern = %ex{full}
> log4j2.appender.jdbc.c5.isUnicode = false
> log4j2.appender.jdbc.c6.type = Column
> log4j2.appender.jdbc.c6.name = CLASS
> log4j2.appender.jdbc.c6.pattern = %class{1.}
> log4j2.appender.jdbc.c6.isUnicode = false
> log4j2.appender.jdbc.c7.type = Column
> log4j2.appender.jdbc.c7.name = THREAD
> log4j2.appender.jdbc.c7.pattern = %thread
> log4j2.appender.jdbc.c7.isUnicode = false
> log4j2.appender.jdbc.datasource.type = DataSource
> log4j2.appender.jdbc.datasource.jndiName = osgi:service/connectors_log_ds
> log4j2.appender.jdbc.filter.f1.type = MarkerFilter
> log4j2.appender.jdbc.filter.f1.onMismatch = DENY
> log4j2.appender.jdbc.filter.f1.onMatch = ACCEPT
> log4j2.appender.jdbc.filter.f1.marker = DB_MARKER
> ================================================================
> 
> And following the error trace that's repeated more times
> 
> 
> 
> 2019-04-09 11:26:39,574 CM Configuration Updater (Update:
> pid=org.ops4j.pax.logging) ERROR Need to specify class name in environment
> or system property, or as an applet parameter, or in an application resource
> file:  java.naming.factory.initial javax.naming.NoInitialContextException:
> Need to specify class name in environment or system property, or as an
> applet parameter, or in an application resource file: 
> java.naming.factory.initial
>         at
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
>         at
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
>         at
> javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:350)
>         at javax.naming.InitialContext.lookup(InitialContext.java:417)
>         at
> org.apache.logging.log4j.core.appender.db.jdbc.DataSourceConnectionSource.createConnectionSource(DataSourceConnectionSource.java:75)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:498)
>         at
> org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:132)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:952)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:892)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:884)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:884)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:508)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:232)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:244)
>         at
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
>         at
> org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
>         at
> org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.doUpdate(PaxLoggingServiceImpl.java:213)
>         at
> org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:158)
>         at
> org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImpl.java:426)
>         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$UpdateConfiguration.run(ConfigurationManager.java:1400)
>         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)
> 
> 2019-04-09 11:26:39,584 CM Configuration Updater (Update:
> pid=org.ops4j.pax.logging) ERROR No ConnectionSource provided:
> connectionSource
> 2019-04-09 11:26:39,594 CM Configuration Updater (Update:
> pid=org.ops4j.pax.logging) ERROR Unable to inject fields into builder class
> for plugin type class
> org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender, element jdbc.
> org.apache.logging.log4j.core.config.ConfigurationException: Arguments given
> for element jdbc are invalid
>         at
> org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:198)
>         at
> org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:121)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:952)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:892)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:884)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:508)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:232)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:244)
>         at
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
>         at
> org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
>         at
> org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.doUpdate(PaxLoggingServiceImpl.java:213)
>         at
> org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:158)
>         at
> org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImpl.java:426)
>         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$UpdateConfiguration.run(ConfigurationManager.java:1400)
>         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)
> 
> 2019-04-09 11:26:39,594 CM Configuration Updater (Update:
> pid=org.ops4j.pax.logging) ERROR Unable to invoke factory method in class
> class org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender for
> element jdbc. java.lang.IllegalStateException: No factory method found for
> class org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender
>         at
> org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:224)
>         at
> org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:130)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:952)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:892)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:884)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:508)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:232)
>         at
> org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:244)
>         at
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
>         at
> org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
>         at
> org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.doUpdate(PaxLoggingServiceImpl.java:213)
>         at
> org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:158)
>         at
> org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImpl.java:426)
>         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$UpdateConfiguration.run(ConfigurationManager.java:1400)
>         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)
> 
> 
> 
> I think the datasource is not instantiated at startup.
> 
> Can you help me to resolve this problem?
> 
> Thanks in advance
> 
> 
> 
> 
> 
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-Dev-f930721.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Mime
View raw message