public class PaxLoggingServiceImpl extends Object implements org.ops4j.pax.logging.PaxLoggingService, org.knopflerfish.service.log.LogService, org.osgi.framework.ServiceFactory<Object>
This implementation is registered with the OSGi ConfigAdmin with a configuration PID of "org.ops4j.pax.logging". That configuration should have a property "org.ops4j.pax.logging.logback.config.file" which should be a path to a Logback Joran XML configuration file.
This class has a fair bit of code copied from from org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl v1.6.0. Changes include:
To sync java.util.logging logger levels with Logback logger levels, be sure to include this in your logback.xml:
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
This is an important performance optimization, as discussed in the Logback docs
| Modifier and Type | Field and Description |
|---|---|
static String |
LOGGER_CONTEXT_BUNDLECONTEXT_KEY |
| Constructor and Description |
|---|
PaxLoggingServiceImpl(org.osgi.framework.BundleContext bundleContext,
org.ops4j.pax.logging.spi.support.LogReaderServiceImpl logReader,
org.ops4j.pax.logging.EventAdminPoster eventAdmin,
org.ops4j.pax.logging.spi.support.ConfigurationNotifier configNotifier,
org.ops4j.pax.logging.PaxLogger logLog) |
| Modifier and Type | Method and Description |
|---|---|
org.ops4j.pax.logging.PaxLogger |
getLogger(org.osgi.framework.Bundle bundle,
String category,
String fqcn) |
int |
getLogLevel() |
org.ops4j.pax.logging.PaxContext |
getPaxContext() |
Object |
getService(org.osgi.framework.Bundle bundle,
org.osgi.framework.ServiceRegistration registration)
Use local class to delegate calls to underlying instance while keeping bundle reference.
|
void |
log(int level,
String message) |
void |
log(int level,
String message,
Throwable exception) |
void |
log(org.osgi.framework.ServiceReference sr,
int level,
String message) |
void |
log(org.osgi.framework.ServiceReference sr,
int level,
String message,
Throwable exception) |
void |
setDefaultConfiguration(Dictionary<String,String> config)
When there's system/context property specified using
PaxLoggingConstants.LOGGING_CFG_PROPERTY_FILE,
and ConfigurationAdmin is available, Pax Logging may first get null configuration. |
void |
shutdown()
Shut down the Pax Logging service.
|
void |
ungetService(org.osgi.framework.Bundle bundle,
org.osgi.framework.ServiceRegistration registration,
Object service) |
void |
updated(Dictionary<String,?> configuration)
ManagedService-like method but not requiring Configuration Admin
|
public static final String LOGGER_CONTEXT_BUNDLECONTEXT_KEY
public PaxLoggingServiceImpl(org.osgi.framework.BundleContext bundleContext,
org.ops4j.pax.logging.spi.support.LogReaderServiceImpl logReader,
org.ops4j.pax.logging.EventAdminPoster eventAdmin,
org.ops4j.pax.logging.spi.support.ConfigurationNotifier configNotifier,
org.ops4j.pax.logging.PaxLogger logLog)
public void shutdown()
LoggerContext.public org.ops4j.pax.logging.PaxLogger getLogger(org.osgi.framework.Bundle bundle,
String category,
String fqcn)
getLogger in interface org.ops4j.pax.logging.PaxLoggingServicepublic int getLogLevel()
getLogLevel in interface org.ops4j.pax.logging.PaxLoggingServicepublic void log(int level,
String message)
log in interface org.osgi.service.log.LogServicepublic void log(int level,
String message,
Throwable exception)
log in interface org.osgi.service.log.LogServicepublic void log(org.osgi.framework.ServiceReference sr,
int level,
String message)
log in interface org.osgi.service.log.LogServicepublic void log(org.osgi.framework.ServiceReference sr,
int level,
String message,
Throwable exception)
log in interface org.osgi.service.log.LogServicepublic org.ops4j.pax.logging.PaxContext getPaxContext()
getPaxContext in interface org.ops4j.pax.logging.PaxLoggingServicepublic void setDefaultConfiguration(Dictionary<String,String> config)
PaxLoggingConstants.LOGGING_CFG_PROPERTY_FILE,
and ConfigurationAdmin is available, Pax Logging may first get null configuration. When "default configuration"
is set before that, we'll use it instead of empty configuration.config - public void updated(Dictionary<String,?> configuration)
configuration - public Object getService(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceRegistration registration)
Use local class to delegate calls to underlying instance while keeping bundle reference.
We don't need anything special from bundle-scoped service (ServiceFactory) except the
reference to client bundle.
getService in interface org.osgi.framework.ServiceFactory<Object>Copyright © 2006–2021 OPS4J - Open Participation Software for Java. All rights reserved.