From 12cb3456d71ecf40cb0111ccbac6242d7676be64 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Fri, 16 Jun 2017 13:17:10 +0900 Subject: [PATCH] HADOOP-14289. Move log4j APIs over to slf4j in hadoop-common. (cherry picked from commit e855cc4ed467d03f4f03e8b3a1ff27654b349a52) --- .../apache/hadoop/http/HttpRequestLog.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpRequestLog.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpRequestLog.java index 52d985042ad..bd4057c6059 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpRequestLog.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpRequestLog.java @@ -24,16 +24,18 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogConfigurationException; import org.apache.commons.logging.LogFactory; import org.apache.log4j.Appender; -import org.apache.log4j.Logger; import org.mortbay.jetty.NCSARequestLog; import org.mortbay.jetty.RequestLog; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * RequestLog object for use with Http */ 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 serverToComponent; static { @@ -65,20 +67,18 @@ public class HttpRequestLog { } if (isLog4JLogger) { Log4JLogger httpLog4JLog = (Log4JLogger)logger; - Logger httpLogger = httpLog4JLog.getLogger(); + org.apache.log4j.Logger httpLogger = httpLog4JLog.getLogger(); Appender appender = null; try { appender = httpLogger.getAppender(appenderName); } catch (LogConfigurationException e) { - LOG.warn("Http request log for " + loggerName - + " could not be created"); + LOG.warn("Http request log for {} could not be created", loggerName); throw e; } if (appender == null) { - LOG.info("Http request log for " + loggerName - + " is not defined"); + LOG.info("Http request log for {} is not defined", loggerName); return null; } @@ -89,14 +89,11 @@ public class HttpRequestLog { requestLog.setFilename(requestLogAppender.getFilename()); requestLog.setRetainDays(requestLogAppender.getRetainDays()); return requestLog; - } - else { - LOG.warn("Jetty request log for " + loggerName - + " was of the wrong class"); + } else { + LOG.warn("Jetty request log for {} was of the wrong class", loggerName); return null; } - } - else { + } else { LOG.warn("Jetty request log can only be enabled using Log4j"); return null; }