diff options
| author | Robert Gemmell <robbie@apache.org> | 2009-08-16 20:36:33 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2009-08-16 20:36:33 +0000 |
| commit | 8a11b9f6df8882fb704955afcdfec3c1e14fd9bd (patch) | |
| tree | 0f0ac65e50b0ccbb282652e1fbdaad47d111b7c4 /qpid/java/broker/src | |
| parent | b964a52247b0405f2f6da647bff3ac74ad2ab6c6 (diff) | |
| download | qpid-python-8a11b9f6df8882fb704955afcdfec3c1e14fd9bd.tar.gz | |
QPID-2052: Enable setting Loggers to inherit their Level from an ancestor. Highlight the Runtime Loggers that have a level defined in the configuration file to aid inheritance visibility.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@804768 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/src')
| -rw-r--r-- | qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java index 1ab9d913c8..ce7d08c8dc 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java @@ -76,10 +76,12 @@ public class LoggingManagementMBean extends AMQManagedObject implements LoggingM private static final Logger _logger = Logger.getLogger(LoggingManagementMBean.class); private String _log4jConfigFileName; private int _log4jLogWatchInterval; + private static final String INHERITED = "INHERITED"; private static final String[] LEVELS = new String[]{Level.ALL.toString(), Level.TRACE.toString(), Level.DEBUG.toString(), Level.INFO.toString(), Level.WARN.toString(), Level.ERROR.toString(), - Level.FATAL.toString(),Level.OFF.toString()}; + Level.FATAL.toString(),Level.OFF.toString(), + INHERITED}; static TabularType _loggerLevelTabularType; static CompositeType _loggerLevelCompositeType; @@ -225,6 +227,13 @@ public class LoggingManagementMBean extends AMQManagedObject implements LoggingM { return false; } + + if(newLevel == null) + { + //A null Level reference implies inheritance. Setting the runtime RootLogger + //to null is catastrophic (and prevented by Log4J at startup and runtime anyway). + return false; + } _logger.info("Setting RootLogger level to " + level); @@ -237,6 +246,13 @@ public class LoggingManagementMBean extends AMQManagedObject implements LoggingM //method to convert from a string to a log4j Level, throws exception if the given value is invalid private Level getLevel(String level) throws Exception { + if("null".equalsIgnoreCase(level) || INHERITED.equalsIgnoreCase(level)) + { + //the string "null" or "inherited" signals to inherit from a parent logger, + //using a null Level reference for the logger. + return null; + } + Level newLevel = Level.toLevel(level); //above Level.toLevel call returns a DEBUG Level if the request fails. Check the result. @@ -611,7 +627,7 @@ public class LoggingManagementMBean extends AMQManagedObject implements LoggingM } //update the element with the new level/priority - levelElement.setAttribute("value", level); + levelElement.setAttribute("value", level.toLowerCase()); //output the new file return writeUpdatedConfigFile(_log4jConfigFileName, doc); @@ -699,7 +715,14 @@ public class LoggingManagementMBean extends AMQManagedObject implements LoggingM //check that the specified level is a valid log4j Level try { - getLevel(level); + Level newLevel = getLevel(level); + if(newLevel == null) + { + //A null Level reference implies inheritance. Setting the config file RootLogger + //to "null" or "inherited" just ensures it defaults to DEBUG at startup as Log4J + //prevents this catastrophic situation at startup and runtime anyway. + return false; + } } catch (Exception e) { |
