3 Replies Latest reply on May 10, 2011 10:26 PM by Freeman(Yue) Fang

    Custom Log4j appender configuration

    Oren Livne Novice

      Dear All,

       

      I am interested in activating my custom Log4J appender (logs messages to the DB AND filters special characters, which Log4J does not provide out of the box) in a single osgi bundle on a FUSE 4.2 bus.

       

      I realize it is not possible to configure a per-bundle log4j because http://fusesource.com/issues/browse/ESB-862 is still open.

       

      So I could configure it globally instead in $FUSE_HOME/etc/org.ops4j.pax.logging.cfg. Still, the PAX Logging Bundle does not recognize my custom class, because it is not on its class loader's classpath. How can I make my appender visible to the PAX bundle classloader?

       

      karaf@root> log4j:ERROR Could not instantiate class .

      java.lang.ClassNotFoundException: edu.utah.further.core.util.log.FilteredJdbcAppender

              at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)

              at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)

              at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)

              at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)

              at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

              at java.lang.Class.forName0(Native Method)

              at java.lang.Class.forName(Class.java:169)

              at org.apache.log4j.helpers.Loader.loadClass(Loader.java:179)

              at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:320)

              at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:121)

              at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:664)

              at org.apache.log4j.PaxLoggingConfigurator.parseAppender(PaxLoggingConfigurator.java:47)

              at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:647)

              at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:568)

              at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:442)

              at org.ops4j.pax.logging.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:180)

              at org.ops4j.pax.logging.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImp

      .java:314)

              at org.apache.felix.cm.impl.ConfigurationManager$UpdateConfiguration.run(ConfigurationManager.java:1389)

              at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:88)

      log4j:ERROR Could not instantiate appender named "DB".

      log4j:ERROR Could not instantiate class .

      java.lang.ClassNotFoundException: edu.utah.further.core.util.log.FilteredJdbcAppender

              at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)

              at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)

              at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)

              at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)

              at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

              at java.lang.Class.forName0(Native Method)

              at java.lang.Class.forName(Class.java:169)

              at org.apache.log4j.helpers.Loader.loadClass(Loader.java:179)

              at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:320)

              at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:121)

              at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:664)

              at org.apache.log4j.PaxLoggingConfigurator.parseAppender(PaxLoggingConfigurator.java:47)

              at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:647)

              at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:568)

              at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:442)

              at org.ops4j.pax.logging.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:180)

              at org.ops4j.pax.logging.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImp

      .java:314)

              at org.apache.felix.cm.impl.ConfigurationManager$UpdateConfiguration.run(ConfigurationManager.java:1389)

              at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:88)

      log4j:ERROR Could not instantiate appender named "DB".

       

      Thanks so much,

      Oren