logging.properties:handlers = org.apache.logging.log4j.jul.Log4jBridgeHandlerorg.apache.logging.log4j.jul.Log4jBridgeHandler.propagateLevels = true )WEB-INF/classes/logging.properties
file to configure JUL for this webapp only: configured handlers and log levels affect your webapp only!
This file is then the complete JUL configuration, so JUL's defaults (e.g. log level INFO) apply
for stuff not explicitly defined therein.
install() method,
e.g. inside ServletContextListener static-class-init. or contextInitialized()
logging.properties):suffixToAppendLog4jBridgeHandler.suffixToAppend = _JULpropagateLevels boolean, "true" to automatically propagate log4j log levels to JUL.
sysoutDebug boolean, perform some (developer) debug output to sysout
LevelTranslator, see also
log4j doc..level = SEVERE only error logs will be seen by this handler and thus log4j
- even if the corresponding log4j log level is ALL..level = FINER or FINEST if the log4j level is higher.
In this case a lot of JUL log events would be generated, sent via this bridge to log4j and thrown away by the latter.| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private static final String | |
| private volatile boolean | |
| private static final Formatter | |
| private Set | julLoggerRefs
Save "hard" references to configured JUL loggers. |
| private String | |
| private static final Logger | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Log4jBridgeHandler(boolean debugOutput, String suffixToAppend, boolean propagateLevels)
Initialize this handler with given configuration. |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements abstract java. Close the |
| public void | |
| private static Logger | |
| private Logger | getLog4jLogger(final LogRecord record)
Return the log4j-Logger instance that will be used for logging. |
| protected void | |
| public static void | |
| private void | propagateLogLevels(final org.
Perform developer tests? |
| public void | propertyChange(final PropertyChangeEvent
A PropertyChangeEvent object describing the event source
and the property that has changed. evt)Implements java. This method gets called when a bound property is changed. |
| public void | publish(final LogRecord
description of the log event. A null record is
silently ignored and is not published record)Implements abstract java. Publish a |
| doDebugOutput | back to summary |
|---|---|
| private boolean doDebugOutput | |
| FQCN | back to summary |
|---|---|
| private static final String FQCN | |
| installAsLevelPropagator | back to summary |
|---|---|
| private volatile boolean installAsLevelPropagator | |
| julFormatter | back to summary |
|---|---|
| private static final Formatter julFormatter | |
| julLoggerRefs | back to summary |
|---|---|
| private Set<Logger> julLoggerRefs Save "hard" references to configured JUL loggers. (is lazy init.) | |
| julSuffixToAppend | back to summary |
|---|---|
| private String julSuffixToAppend | |
| SLOGGER | back to summary |
|---|---|
| private static final Logger SLOGGER | |
| UNKNOWN_LOGGER_NAME | back to summary |
|---|---|
| private static final String UNKNOWN_LOGGER_NAME | |
| Log4jBridgeHandler | back to summary |
|---|---|
| public Log4jBridgeHandler() Initialize this handler by reading out JUL configuration. | |
| Log4jBridgeHandler | back to summary |
|---|---|
| public Log4jBridgeHandler(boolean debugOutput, String suffixToAppend, boolean propagateLevels) Initialize this handler with given configuration. | |
| close | back to summary |
|---|---|
| public void close() Implements abstract java. Doc from java. Close the
The close method will perform a
| |
| flush | back to summary |
|---|---|
| public void flush() Implements abstract java. Doc from java. Flush any buffered output.
| |
| getJulRootLogger | back to summary |
|---|---|
| private static Logger getJulRootLogger() | |
| getLog4jLogger | back to summary |
|---|---|
| private Logger getLog4jLogger(final LogRecord record) Return the log4j-Logger instance that will be used for logging. Handles null name case and appends configured suffix. | |
| init | back to summary |
|---|---|
| protected void init(boolean debugOutput, String suffixToAppend, boolean propagateLevels) Perform init. of this handler with given configuration (typical use is for constructor).
| |
| install | back to summary |
|---|---|
| public static void install(boolean removeHandlersForRootLogger, String suffixToAppend, boolean propagateLevels) Adds a new Log4jBridgeHandler instance to JUL's root logger.
This is a programmatic alternative to specify
| |
| propagateLogLevels | back to summary |
|---|---|
| private void propagateLogLevels(final org. Perform developer tests? (Should be unused/outcommented for real code) | |
| propertyChange | back to summary |
|---|---|
| public void propertyChange(final PropertyChangeEvent evt) Implements java. Doc from java. This method gets called when a bound property is changed.
| |
| publish | back to summary |
|---|---|
| public void publish(final LogRecord record) Implements abstract java. Doc from java. Publish a
The logging request was made initially to a
The | |