SOLR-4868: fix inability to set root logger in Log4JWatcher

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1487294 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shawn Heisey 2013-05-29 06:02:17 +00:00
parent ee096e5cf8
commit a79ffdfeee
2 changed files with 7 additions and 2 deletions

View File

@ -204,6 +204,9 @@ Bug Fixes
* SOLR-4734: Leader election fails with an NPE if there is no UpdateLog. * SOLR-4734: Leader election fails with an NPE if there is no UpdateLog.
(Mark Miller, Alexander Eibner) (Mark Miller, Alexander Eibner)
* SOLR-4868: Setting the log level for the log4j root category results in
adding a new category, the empty string. (Shawn Heisey)
Other Changes Other Changes
---------------------- ----------------------

View File

@ -66,10 +66,12 @@ public class Log4jWatcher extends LogWatcher<LoggingEvent> {
@Override @Override
public void setLogLevel(String category, String level) { public void setLogLevel(String category, String level) {
org.apache.log4j.Logger log;
if(LoggerInfo.ROOT_NAME.equals(category)) { if(LoggerInfo.ROOT_NAME.equals(category)) {
category = ""; log = org.apache.log4j.LogManager.getRootLogger();
} else {
log = org.apache.log4j.Logger.getLogger(category);
} }
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(category);
if(level==null||"unset".equals(level)||"null".equals(level)) { if(level==null||"unset".equals(level)||"null".equals(level)) {
log.setLevel(null); log.setLevel(null);
} }