use of org.apache.commons.logging.impl.Log4JLogger in project hadoop by apache.
the class NavBlock method render.
@Override
protected void render(Block html) {
boolean addErrorsAndWarningsLink = false;
Log log = LogFactory.getLog(NMErrorsAndWarningsPage.class);
if (log instanceof Log4JLogger) {
Log4jWarningErrorMetricsAppender appender = Log4jWarningErrorMetricsAppender.findAppender();
if (appender != null) {
addErrorsAndWarningsLink = true;
}
}
String RMWebAppURL = WebAppUtils.getResolvedRMWebAppURLWithScheme(this.conf);
Hamlet.UL<Hamlet.DIV<Hamlet>> ul = html.div("#nav").h3()._("ResourceManager")._().ul().li().a(RMWebAppURL, "RM Home")._()._().h3()._("NodeManager")._().ul().li().a(url("node"), "Node Information")._().li().a(url("allApplications"), "List of Applications")._().li().a(url("allContainers"), "List of Containers")._()._().h3("Tools").ul().li().a("/conf", "Configuration")._().li().a("/logs", "Local logs")._().li().a("/stacks", "Server stacks")._().li().a("/jmx?qry=Hadoop:*", "Server metrics")._();
if (addErrorsAndWarningsLink) {
ul.li().a(url("errors-and-warnings"), "Errors/Warnings")._();
}
ul._()._();
}
use of org.apache.commons.logging.impl.Log4JLogger in project hadoop by apache.
the class TestNativeAzureFileSystemClientLogging method testLoggingEnabled.
@Test
public void testLoggingEnabled() throws Exception {
LogCapturer logs = LogCapturer.captureLogs(new Log4JLogger(Logger.getRootLogger()));
// Update configuration based on the Test.
updateFileSystemConfiguration(true);
performWASBOperations();
assertTrue(verifyStorageClientLogs(logs.getOutput(), TEMP_DIR));
}
use of org.apache.commons.logging.impl.Log4JLogger in project hadoop by apache.
the class NavBlock method render.
@Override
public void render(Block html) {
boolean addErrorsAndWarningsLink = false;
Log log = LogFactory.getLog(NavBlock.class);
if (log instanceof Log4JLogger) {
Log4jWarningErrorMetricsAppender appender = Log4jWarningErrorMetricsAppender.findAppender();
if (appender != null) {
addErrorsAndWarningsLink = true;
}
}
Hamlet.DIV<Hamlet> nav = html.div("#nav").h3("Application History").ul().li().a(url("about"), "About")._().li().a(url("apps"), "Applications").ul().li().a(url("apps", YarnApplicationState.FINISHED.toString()), YarnApplicationState.FINISHED.toString())._().li().a(url("apps", YarnApplicationState.FAILED.toString()), YarnApplicationState.FAILED.toString())._().li().a(url("apps", YarnApplicationState.KILLED.toString()), YarnApplicationState.KILLED.toString())._()._()._()._();
Hamlet.UL<Hamlet.DIV<Hamlet>> tools = nav.h3("Tools").ul();
tools.li().a("/conf", "Configuration")._().li().a("/logs", "Local logs")._().li().a("/stacks", "Server stacks")._().li().a("/jmx?qry=Hadoop:*", "Server metrics")._();
if (addErrorsAndWarningsLink) {
tools.li().a(url("errors-and-warnings"), "Errors/Warnings")._();
}
tools._()._();
}
use of org.apache.commons.logging.impl.Log4JLogger in project hadoop by apache.
the class AdHocLogDumper method dumpLogs.
public void dumpLogs(String level, int timePeriod) throws YarnRuntimeException, IOException {
synchronized (lock) {
if (logFlag) {
LOG.info("Attempt to dump logs when appender is already running");
throw new YarnRuntimeException("Appender is already dumping logs");
}
Level targetLevel = Level.toLevel(level);
Log log = LogFactory.getLog(name);
appenderLevels.clear();
if (log instanceof Log4JLogger) {
Logger packageLogger = ((Log4JLogger) log).getLogger();
currentLogLevel = packageLogger.getLevel();
Level currentEffectiveLevel = packageLogger.getEffectiveLevel();
// make sure we can create the appender first
Layout layout = new PatternLayout("%d{ISO8601} %p %c: %m%n");
FileAppender fApp;
File file = new File(System.getProperty("yarn.log.dir"), targetFilename);
try {
fApp = new FileAppender(layout, file.getAbsolutePath(), false);
} catch (IOException ie) {
LOG.warn("Error creating file, can't dump logs to " + file.getAbsolutePath(), ie);
throw ie;
}
fApp.setName(AdHocLogDumper.AD_HOC_DUMPER_APPENDER);
fApp.setThreshold(targetLevel);
// level
for (Enumeration appenders = Logger.getRootLogger().getAllAppenders(); appenders.hasMoreElements(); ) {
Object obj = appenders.nextElement();
if (obj instanceof AppenderSkeleton) {
AppenderSkeleton appender = (AppenderSkeleton) obj;
appenderLevels.put(appender.getName(), appender.getThreshold());
appender.setThreshold(currentEffectiveLevel);
}
}
packageLogger.addAppender(fApp);
LOG.info("Dumping adhoc logs for " + name + " to " + file.getAbsolutePath() + " for " + timePeriod + " milliseconds");
packageLogger.setLevel(targetLevel);
logFlag = true;
TimerTask restoreLogLevel = new RestoreLogLevel();
Timer restoreLogLevelTimer = new Timer();
restoreLogLevelTimer.schedule(restoreLogLevel, timePeriod);
}
}
}
use of org.apache.commons.logging.impl.Log4JLogger in project hbase by apache.
the class HttpRequestLog method getRequestLog.
public static RequestLog getRequestLog(String name) {
String lookup = serverToComponent.get(name);
if (lookup != null) {
name = lookup;
}
String loggerName = "http.requests." + name;
String appenderName = name + "requestlog";
Log logger = LogFactory.getLog(loggerName);
if (logger instanceof Log4JLogger) {
Log4JLogger httpLog4JLog = (Log4JLogger) logger;
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");
throw e;
}
if (appender == null) {
LOG.info("Http request log for " + loggerName + " is not defined");
return null;
}
if (appender instanceof HttpRequestLogAppender) {
HttpRequestLogAppender requestLogAppender = (HttpRequestLogAppender) appender;
NCSARequestLog requestLog = new NCSARequestLog();
requestLog.setFilename(requestLogAppender.getFilename());
requestLog.setRetainDays(requestLogAppender.getRetainDays());
return requestLog;
} else {
LOG.warn("Jetty request log for " + loggerName + " was of the wrong class");
return null;
}
} else {
LOG.warn("Jetty request log can only be enabled using Log4j");
return null;
}
}
Aggregations