HADOOP-14289. Move log4j APIs over to slf4j in hadoop-common.
(cherry picked from commit e855cc4ed4
)
This commit is contained in:
parent
abac844c90
commit
12cb3456d7
|
@ -24,16 +24,18 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogConfigurationException;
|
import org.apache.commons.logging.LogConfigurationException;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.log4j.Appender;
|
import org.apache.log4j.Appender;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.mortbay.jetty.NCSARequestLog;
|
import org.mortbay.jetty.NCSARequestLog;
|
||||||
import org.mortbay.jetty.RequestLog;
|
import org.mortbay.jetty.RequestLog;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RequestLog object for use with Http
|
* RequestLog object for use with Http
|
||||||
*/
|
*/
|
||||||
public class HttpRequestLog {
|
public class HttpRequestLog {
|
||||||
|
|
||||||
public static final Log LOG = LogFactory.getLog(HttpRequestLog.class);
|
public static final Logger LOG =
|
||||||
|
LoggerFactory.getLogger(HttpRequestLog.class);
|
||||||
private static final HashMap<String, String> serverToComponent;
|
private static final HashMap<String, String> serverToComponent;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -65,20 +67,18 @@ public class HttpRequestLog {
|
||||||
}
|
}
|
||||||
if (isLog4JLogger) {
|
if (isLog4JLogger) {
|
||||||
Log4JLogger httpLog4JLog = (Log4JLogger)logger;
|
Log4JLogger httpLog4JLog = (Log4JLogger)logger;
|
||||||
Logger httpLogger = httpLog4JLog.getLogger();
|
org.apache.log4j.Logger httpLogger = httpLog4JLog.getLogger();
|
||||||
Appender appender = null;
|
Appender appender = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
appender = httpLogger.getAppender(appenderName);
|
appender = httpLogger.getAppender(appenderName);
|
||||||
} catch (LogConfigurationException e) {
|
} catch (LogConfigurationException e) {
|
||||||
LOG.warn("Http request log for " + loggerName
|
LOG.warn("Http request log for {} could not be created", loggerName);
|
||||||
+ " could not be created");
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appender == null) {
|
if (appender == null) {
|
||||||
LOG.info("Http request log for " + loggerName
|
LOG.info("Http request log for {} is not defined", loggerName);
|
||||||
+ " is not defined");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,14 +89,11 @@ public class HttpRequestLog {
|
||||||
requestLog.setFilename(requestLogAppender.getFilename());
|
requestLog.setFilename(requestLogAppender.getFilename());
|
||||||
requestLog.setRetainDays(requestLogAppender.getRetainDays());
|
requestLog.setRetainDays(requestLogAppender.getRetainDays());
|
||||||
return requestLog;
|
return requestLog;
|
||||||
}
|
} else {
|
||||||
else {
|
LOG.warn("Jetty request log for {} was of the wrong class", loggerName);
|
||||||
LOG.warn("Jetty request log for " + loggerName
|
|
||||||
+ " was of the wrong class");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
LOG.warn("Jetty request log can only be enabled using Log4j");
|
LOG.warn("Jetty request log can only be enabled using Log4j");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue