directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John E. Conlon" <jcon...@verticon.com>
Subject Re: Upgrading the OSGi
Date Thu, 27 Apr 2006 17:53:45 GMT
On Thu, 2006-04-27 at 17:21 +0200, Ceki Gülcü wrote:
> I recently read part of the OSGI spec to become familiar with it. Is there 
> any support you would like to see included directly in SLF4J that could 
> make life easier for you?


There are some issues that just started showing up with the latest
builds of felix that are related to SLF4J 
(actually NLOG4J).

My logging bundle includes both 

  <artifactId>jcl104-over-slf4j</artifactId
  <version>1.0</version>
	

  <artifactId>nlog4j</artifactId>
  <version>1.2.24</version>
   
When felix starts the bundle I now am getting the following errors when
it trys to log to the console.

DEBUG: WIRE: [7.0] 7.0 -> org.osgi.framework -> 0
DEBUG: WIRE: [7.0] 7.0 -> org.apache.log4j -> 7.0
DEBUG: WIRE: [7.0] 7.0 -> org.slf4j -> 7.0
DEBUG: WIRE: [7.0] 7.0 -> org.apache.commons.logging -> 7.0
ERROR: ****
****
Package 'org.apache.log4j' is imported by bundle 7 from bundle 7, but
the export ed package from bundle 7 does not contain the requested class
'org.apache.log4j. PatternLayoutBeanInfo'. Please verify that the class
name is correct in the impo rting bundle 7 and/or that the exported
package is correctly bundled in 7.
****
****
ERROR: ****
****
Package 'org.apache.log4j' is imported by bundle 7 from bundle 7, but
the export ed package from bundle 7 does not contain the requested class
'org.apache.log4j. LayoutBeanInfo'. Please verify that the class name is
correct in the importing b undle 7 and/or that the exported package is
correctly bundled in 7.
****
****

Errors look to be related to the log4j.properties file. Everything
works, though.

kind regards,
John

> Cheers,
> 
> At 05:16 PM 4/27/2006, you wrote:
> >On Wed, 2006-04-26 at 19:41 -0400, Enrique Rodriguez wrote:
> > > On 4/26/06, John E. Conlon <jconlon@verticon.com> wrote:
> > > > On Tue, 2006-04-25 at 18:01 -0400, Enrique Rodriguez wrote:
> > > ...
> > > > >  I made a 'main' module that will
> > > > > assemble ApacheDS deps with the Felix runtime and startup with an
> > > > > ApacheDS Felix "profile."  I just committed this on rev 396981.
> > > >
> > > > Yes I see it. Very nice.
> > > >
> > > > But, why the new org.apache.directory.server.Main class? Couldn't you
> > > > have reused Felix's main?
> > >
> > > Hmm, good point.  I copied it as a start and, in retrospect, it ended
> > > up unchanged.  I'll update to copy in the Felix main jar and test.
> > >
> > > ...
> > > > Should the log4j.properties file go in the conf directory with the other
> > > > the properties files?
> > >
> > > Sure.  That would be consistent with Felix convention.
> > >
> > > > Regarding logging, I needed to create a similar logging bundle to yours
> > > > because some of my other bundles had transitive dependencies on commons-
> > > > logging as well, so I added jcl104-over-slf4j. While at it, I added  an
> > > > Activator that reset the configuration at start time. Now no need to
> > > > restart the framework after changing the log4j.properties file, just
> > > > stop and start the log bundle.
> > >
> > > That's a nice feature.  I did my POM wrapper to get things working.  I
> > > don't plan on making any logging breakthroughs.  At some point we can
> > > check out how any logging bundles out there turn out.
> >
> >Too many choices for logging - Commons-Logging vs slf4j vs OSGi
> >logService it is as bad as choosing an American Health Care plan.
> >
> >For what it's worth, below is a copy of the logging bundle Activator.
> >
> >--------------------------------------------
> >import java.io.FileNotFoundException;
> >import java.net.MalformedURLException;
> >import java.net.URL;
> >
> >import org.apache.log4j.LogManager;
> >import org.apache.log4j.PropertyConfigurator;
> >import org.osgi.framework.BundleActivator;
> >import org.osgi.framework.BundleContext;
> >import org.slf4j.Logger;
> >import org.slf4j.LoggerFactory;
> >
> >public class Activator implements BundleActivator {
> >   private static final String LOG_PROPERTIES_LOCATION =
> >    "log4j.configuration";
> >
> >   private Logger log = null;
> >
> >   public void start(BundleContext bundleContext) throws Exception {
> >                 try {
> >                         resetLog4j(bundleContext);
> >                 } catch (Exception e) {
> >                         //e.printStackTrace();
> >                 }
> >                 log = LoggerFactory.getLogger(Activator.class);
> >                 log.debug("Reset log configuration.");
> >         }
> >
> >   public void stop(BundleContext arg0) throws Exception {}
> >
> >   /**
> >    * @return url of the log4j.properties configuration file
> >    *
> >    * @throws MalformedURLException
> >    *
> >    */
> >   private URL getLoggingProperty(BundleContext bundleContext)
> >                         throws MalformedURLException {
> >                 final String logPropertiesLocation = bundleContext
> >                                 .getProperty(LOG_PROPERTIES_LOCATION);
> >                 return new URL(logPropertiesLocation);
> >   }
> >
> >   /**
> >    * Reset the log4j configuration.
> >    * @param bundleContext
> >    * @throws MalformedURLException
> >    * @throws FileNotFoundException
> >    */
> >   private void resetLog4j(BundleContext bundleContext)
> >                         throws MalformedURLException,
> >                               FileNotFoundException {
> >
> >     LogManager.resetConfiguration();
> >     URL log4jprops = getLoggingProperty(bundleContext);
> >
> >     if (log4jprops != null) {
> >       PropertyConfigurator.configure(log4jprops);
> >     } else {
> >       throw new FileNotFoundException(bundleContext
> >         .getProperty(LOG_PROPERTIES_LOCATION)
> >         + " could not be found. "
> >         + "Please specify add the file and restart the "
> >         + bundleContext.getBundle().getLocation() + " bundle.");
> >     }
> >   }
> >
> >}
> 


Mime
View raw message