org.mortbay.jetty.RequestLog Java Examples

The following examples show how to use org.mortbay.jetty.RequestLog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestHttpRequestLog.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testAppenderDefined() {
  HttpRequestLogAppender requestLogAppender = new HttpRequestLogAppender();
  requestLogAppender.setName("testrequestlog");
  Logger.getLogger("http.requests.test").addAppender(requestLogAppender);
  RequestLog requestLog = HttpRequestLog.getRequestLog("test");
  Logger.getLogger("http.requests.test").removeAppender(requestLogAppender);
  assertNotNull("RequestLog should not be null", requestLog);
  assertEquals("Class mismatch", NCSARequestLog.class, requestLog.getClass());
}
 
Example #2
Source File: TestHttpRequestLog.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testAppenderDefined() {
  HttpRequestLogAppender requestLogAppender = new HttpRequestLogAppender();
  requestLogAppender.setName("testrequestlog");
  Logger.getLogger("http.requests.test").addAppender(requestLogAppender);
  RequestLog requestLog = HttpRequestLog.getRequestLog("test");
  Logger.getLogger("http.requests.test").removeAppender(requestLogAppender);
  assertNotNull("RequestLog should not be null", requestLog);
  assertEquals("Class mismatch", NCSARequestLog.class, requestLog.getClass());
}
 
Example #3
Source File: HttpRequestLog.java    From big-c with Apache License 2.0 4 votes vote down vote up
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);

    boolean isLog4JLogger;;
    try {
      isLog4JLogger = logger instanceof Log4JLogger;
    } catch (NoClassDefFoundError err) {
      // In some dependent projects, log4j may not even be on the classpath at
      // runtime, in which case the above instanceof check will throw
      // NoClassDefFoundError.
      LOG.debug("Could not load Log4JLogger class", err);
      isLog4JLogger = false;
    }
    if (isLog4JLogger) {
      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;
    }
  }
 
Example #4
Source File: Jetty6PluginServer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setRequestLog(Object requestLog) {
    this.requestLog = (RequestLog) requestLog;
}
 
Example #5
Source File: AbstractJettyRunTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setRequestLog(RequestLog requestLog) {
    this.requestLog = requestLog;
}
 
Example #6
Source File: AbstractJettyRunTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RequestLog getRequestLog() {
    return requestLog;
}
 
Example #7
Source File: Jetty6PluginServer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setRequestLog(Object requestLog) {
    this.requestLog = (RequestLog) requestLog;
}
 
Example #8
Source File: AbstractJettyRunTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setRequestLog(RequestLog requestLog) {
    this.requestLog = requestLog;
}
 
Example #9
Source File: AbstractJettyRunTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RequestLog getRequestLog() {
    return requestLog;
}
 
Example #10
Source File: TestHttpRequestLog.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testAppenderUndefined() {
  RequestLog requestLog = HttpRequestLog.getRequestLog("test");
  assertNull("RequestLog should be null", requestLog);
}
 
Example #11
Source File: AbstractJettyRunTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RequestLog getRequestLog() {
    return requestLog;
}
 
Example #12
Source File: TestHttpRequestLog.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testAppenderUndefined() {
  RequestLog requestLog = HttpRequestLog.getRequestLog("test");
  assertNull("RequestLog should be null", requestLog);
}
 
Example #13
Source File: HttpRequestLog.java    From hadoop with Apache License 2.0 4 votes vote down vote up
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);

    boolean isLog4JLogger;;
    try {
      isLog4JLogger = logger instanceof Log4JLogger;
    } catch (NoClassDefFoundError err) {
      // In some dependent projects, log4j may not even be on the classpath at
      // runtime, in which case the above instanceof check will throw
      // NoClassDefFoundError.
      LOG.debug("Could not load Log4JLogger class", err);
      isLog4JLogger = false;
    }
    if (isLog4JLogger) {
      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;
    }
  }
 
Example #14
Source File: Jetty6PluginServer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setRequestLog(Object requestLog) {
    this.requestLog = (RequestLog) requestLog;
}
 
Example #15
Source File: AbstractJettyRunTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setRequestLog(RequestLog requestLog) {
    this.requestLog = requestLog;
}
 
Example #16
Source File: AbstractJettyRunTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RequestLog getRequestLog() {
    return requestLog;
}
 
Example #17
Source File: Jetty6PluginServer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setRequestLog(Object requestLog) {
    this.requestLog = (RequestLog) requestLog;
}
 
Example #18
Source File: AbstractJettyRunTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setRequestLog(RequestLog requestLog) {
    this.requestLog = requestLog;
}