public class Log4jBridgeHandler extends Handler implements PropertyChangeListener
logging.properties
:handlers = org.apache.logging.log4j.jul.Log4jBridgeHandler
org.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
):suffixToAppend
Log4jBridgeHandler.suffixToAppend = _JUL
propagateLevels
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.Constructor and Description |
---|
Log4jBridgeHandler()
Initialize this handler by reading out JUL configuration.
|
Log4jBridgeHandler(boolean debugOutput,
String suffixToAppend,
boolean propagateLevels)
Initialize this handler with given configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
protected void |
init(boolean debugOutput,
String suffixToAppend,
boolean propagateLevels)
Perform init.
|
static void |
install(boolean removeHandlersForRootLogger,
String suffixToAppend,
boolean propagateLevels)
Adds a new Log4jBridgeHandler instance to JUL's root logger.
|
void |
propertyChange(PropertyChangeEvent evt) |
void |
publish(LogRecord record) |
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
public Log4jBridgeHandler()
public Log4jBridgeHandler(boolean debugOutput, String suffixToAppend, boolean propagateLevels)
public static void install(boolean removeHandlersForRootLogger, String suffixToAppend, boolean propagateLevels)
handlers = org.apache.logging.log4j.jul.Log4jBridgeHandler
and its configuration in logging.properties.removeHandlersForRootLogger
- true to remove all other installed handlers on JUL root levelprotected void init(boolean debugOutput, String suffixToAppend, boolean propagateLevels)
public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
Copyright © 1999-1969 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.