It is doable, but you will need to implement a new service bundle for Pax Logging.
The tricky bit is that on one hand, you need Pax Logging's SLF4J classes to be used internally in the OSGi container, yet you need to "reach" those classes on the outside. What you should do is a bundle that implements the Pax Logging service, and pass it from the containing application when Felix is booted. That gives you enough bridge to be on both sides of the container barrier, without too much classloader issues. I don't recall the details for how Felix accepts bundles from the outside, but I have done it in the past. Since Pax Logging doesn't introduce a classloader dependency from its API to its service bundle, this should work without classloading issues. I normally don't watch this list too often, so CC me if you have further questions once you are on the way. Cheers Niclas On Tue, Aug 9, 2016 at 10:47 PM, <[email protected]> wrote: > Hello! > > I've recently stumbled across the pax-logging project and am curious if > it is able to support the following slightly convoluted deployment > configuration. > > The relevant points are: > > * The OSGi container is embedded within an application that already > has its own SLF4J logging. I don't care which backend is used (it's > currently logback-classic, but I don't mind switching to log4j if > necessary). > > * The OSGi container contains a mix of code that is both OSGi-aware > and OSGI-unaware. That is, some of the code uses the standard OSGi log > service, and the rest of it uses SLF4J. > > I would like to do the following, if possible: > > 1. The main application controls the SLF4J/logback/log4j configuration, > logging all messages to a rolling log appender. The main application > (the "host") doesn't do much before starting the OSGi container, but > I would still like it to be the host that's in control of logging. > > 2. Any messages generated by the OSGi framework (Felix in this case, > but I don't think it matters which I use) should go to the host's > SLF4J logging configuration. > > 3. Any messages logged by code running inside the OSGi container that's > using the OSGi log service should go to the host's SLF4J logging > configuration. > > 4. Any messages logged by code inside the OSGi container that's using > SLF4J should to the host's SLF4J logging configuration. > > Basically, I want to guarantee that every single log message is > captured and that all of the the messages end up at the same > destination so that I'm configuring logging in one place instead of > multiple. > > Is this doable with pax-logging? Am I likely to suffer greatly trying > to achieve it? > > Thanks, > Mark > > -- > -- > ------------------ > OPS4J - http://www.ops4j.org - [email protected] > > --- > You received this message because you are subscribed to the Google Groups > "OPS4J" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Niclas Hedhman, Software Developer http://zest.apache.org - New Energy for Java -- -- ------------------ OPS4J - http://www.ops4j.org - [email protected] --- You received this message because you are subscribed to the Google Groups "OPS4J" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
