|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.logging.julbridge.JULLog4jBridge
public class JULLog4jBridge
Helper class that creates bridge filters between java.util.logging.Loggers and an equivalent log4j Logger.
The bridge-style method calls use a Filter
implementation that tries to minimise interference with the existing
java.util.logging configuration, but can only bridge specific
named loggers, and is not able to bridge child loggers automatically. Any
Logger that is bridged that contains an existing Filter instance is delegated
to when deciding if the LogRecord should continue in the java.util.logging
framework, even though the bridge posts the LogRecord into log4j regardless.
If there was no existing Filter defined for the bridged Logger, then the
bridging Filter returns 'true' to mimic the default behaviour of not having a
Filter defined.
The assimilate-style methods are much more dramatic, in that
they are designed to completely take over the JUL-logging, and route all
events into log4j. This mechanism resets the java.util.logging framework
configuration to it's default state, which has default Level
configured at INFO, and then configures the root JUL Logger with the matching
Level that the provided LoggerRepository has been configured. You should,
therefore, assimilate the JUL logging system after the log4j system has been
properly configured. You should consider whether the default
JULLevelConverter is appropriate to your needs, you may optionally
provide your own conversion instance to map the 2 Level classes.
The assimilate approach is very useful for the general case where you wish to
forget about JUL logging and use the flexibility of the log4j system. There
is an ever so slightly higher cost in routing the event into log4j using this
approach because each LogRecord received must lookup a named Logger.
The bridge-style approach is slightly faster because the
specifically requested logger name is looked-up on construction and re-used.
Generally though, the slight performance hit is not worth the inflexibility
of having to specify each and every Logger you want to bridge.
JULLevelConverter,
JULLog4jEventConverter.DEFAULT_LEVEL_CONVERTER| Constructor Summary | |
|---|---|
JULLog4jBridge()
|
|
| Method Summary | |
|---|---|
static void |
assimilate()
|
static void |
assimilate(org.apache.log4j.spi.LoggerRepository repository)
|
static void |
assimilate(org.apache.log4j.spi.LoggerRepository repository,
JULLevelConverter levelConverter)
Completely take over the underlying java.logging sub-system. |
static void |
bridgeJULLogger(java.lang.String JULLoggerName)
Convenience method that gathers the default LoggerRepository and uses a default Level Converter implemenation. |
static void |
bridgeJULLogger(java.lang.String JULLoggerName,
org.apache.log4j.spi.LoggerRepository repository)
|
static void |
bridgeJULLogger(java.lang.String JULLoggerName,
org.apache.log4j.spi.LoggerRepository repository,
JULLevelConverter levelConverter)
Creates a bridge between the named java.util.logging Logger name, and an equivalent inside the log4j LoggerRepository, using the provided level converter class. |
static void |
repatriate()
Reverse of assimilate(), disconnects the bridge from the
java.util.logging subsystem by resetting that framework back to it's
default configuration (removes all Handlers and Filters) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JULLog4jBridge()
| Method Detail |
|---|
public static void bridgeJULLogger(java.lang.String JULLoggerName)
JULLoggerName -
public static void bridgeJULLogger(java.lang.String JULLoggerName,
org.apache.log4j.spi.LoggerRepository repository)
public static void bridgeJULLogger(java.lang.String JULLoggerName,
org.apache.log4j.spi.LoggerRepository repository,
JULLevelConverter levelConverter)
JULLoggerName - repository -
public static void assimilate(org.apache.log4j.spi.LoggerRepository repository,
JULLevelConverter levelConverter)
public static void assimilate(org.apache.log4j.spi.LoggerRepository repository)
public static void assimilate()
public static void repatriate()
assimilate(), disconnects the bridge from the
java.util.logging subsystem by resetting that framework back to it's
default configuration (removes all Handlers and Filters)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||