javax.servlet.ServletContext.log()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中javax.servlet.ServletContext.log()方法的一些代码示例,展示了ServletContext.log()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ServletContext.log()方法的具体详情如下:
包路径:javax.servlet.ServletContext
类名称:ServletContext
方法名:log

ServletContext.log介绍

[英]Do not use.
[中]不要使用。

代码示例

代码示例来源:origin: igniterealtime/Openfire

@Override
public void log( Exception e, String s )
{
  proxy.log( e, s );
}

代码示例来源:origin: igniterealtime/Openfire

@Override
public void log( String s, Throwable throwable )
{
  proxy.log( s, throwable );
}

代码示例来源:origin: igniterealtime/Openfire

@Override
public void log( String s )
{
  proxy.log( s );
}

代码示例来源:origin: stanfordnlp/CoreNLP

private void log(String message) {
  if (loggingEnabled) {
    filterConfig.getServletContext().log(message);
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Writes a log message after the request is processed.
 */
@Override
protected void afterRequest(HttpServletRequest request, String message) {
  getServletContext().log(message);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Writes a log message before the request is processed.
 */
@Override
protected void beforeRequest(HttpServletRequest request, String message) {
  getServletContext().log(message);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Close the WebApplicationContext of this servlet.
 * @see org.springframework.context.ConfigurableApplicationContext#close()
 */
@Override
public void destroy() {
  getServletContext().log("Destroying Spring FrameworkServlet '" + getServletName() + "'");
  // Only call close() on WebApplicationContext if locally managed...
  if (this.webApplicationContext instanceof ConfigurableApplicationContext && !this.webApplicationContextInjected) {
    ((ConfigurableApplicationContext) this.webApplicationContext).close();
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Close Spring's web application context for the given servlet context.
 * <p>If overriding {@link #loadParentContext(ServletContext)}, you may have
 * to override this method as well.
 * @param servletContext the ServletContext that the WebApplicationContext runs in
 */
public void closeWebApplicationContext(ServletContext servletContext) {
  servletContext.log("Closing Spring root WebApplicationContext");
  try {
    if (this.context instanceof ConfigurableWebApplicationContext) {
      ((ConfigurableWebApplicationContext) this.context).close();
    }
  }
  finally {
    ClassLoader ccl = Thread.currentThread().getContextClassLoader();
    if (ccl == ContextLoader.class.getClassLoader()) {
      currentContext = null;
    }
    else if (ccl != null) {
      currentContextPerThread.remove(ccl);
    }
    servletContext.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
  }
}

代码示例来源:origin: spring-projects/spring-framework

servletContext.log("Set web app root system property: '" + key + "' = [" + root + "]");

代码示例来源:origin: org.springframework/spring-web

/**
 * Writes a log message after the request is processed.
 */
@Override
protected void afterRequest(HttpServletRequest request, String message) {
  getServletContext().log(message);
}

代码示例来源:origin: org.springframework/spring-web

/**
 * Writes a log message before the request is processed.
 */
@Override
protected void beforeRequest(HttpServletRequest request, String message) {
  getServletContext().log(message);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public Collection<ApplicationResource> getResources(String path) {
  Resource[] resources;
  try {
    resources = this.resolver.getResources(path);
  }
  catch (IOException ex) {
    ((ServletContext) getContext()).log("Resource retrieval failed for path: " + path, ex);
    return Collections.emptyList();
  }
  if (ObjectUtils.isEmpty(resources)) {
    ((ServletContext) getContext()).log("No resources found for path pattern: " + path);
    return Collections.emptyList();
  }
  Collection<ApplicationResource> resourceList = new ArrayList<>(resources.length);
  for (Resource resource : resources) {
    try {
      URL url = resource.getURL();
      resourceList.add(new URLApplicationResource(url.toExternalForm(), url));
    }
    catch (IOException ex) {
      // Shouldn't happen with the kind of resources we're using
      throw new IllegalArgumentException("No URL for " + resource, ex);
    }
  }
  return resourceList;
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Overridden method of {@link HttpServletBean}, invoked after any bean properties
 * have been set. Creates this servlet's WebApplicationContext.
 */
@Override
protected final void initServletBean() throws ServletException {
  getServletContext().log("Initializing Spring " + getClass().getSimpleName() + " '" + getServletName() + "'");
  if (logger.isInfoEnabled()) {
    logger.info("Initializing Servlet '" + getServletName() + "'");
  }
  long startTime = System.currentTimeMillis();
  try {
    this.webApplicationContext = initWebApplicationContext();
    initFrameworkServlet();
  }
  catch (ServletException | RuntimeException ex) {
    logger.error("Context initialization failed", ex);
    throw ex;
  }
  if (logger.isDebugEnabled()) {
    String value = this.enableLoggingRequestDetails ?
        "shown which may lead to unsafe logging of potentially sensitive data" :
        "masked to prevent unsafe logging of potentially sensitive data";
    logger.debug("enableLoggingRequestDetails='" + this.enableLoggingRequestDetails +
        "': request parameters and headers will be " + value);
  }
  if (logger.isInfoEnabled()) {
    logger.info("Completed initialization in " + (System.currentTimeMillis() - startTime) + " ms");
  }
}

代码示例来源:origin: javax.servlet/servlet-api

/**
 * 
 * Writes the specified message to a servlet log file, prepended by the
 * servlet's name.  See {@link ServletContext#log(String)}.
 *
 * @param msg     a <code>String</code> specifying
 *            the message to be written to the log file
 *
 */
 public void log(String msg) {
getServletContext().log(getServletName() + ": "+ msg);
}

代码示例来源:origin: org.springframework/spring-webmvc

/**
 * Close the WebApplicationContext of this servlet.
 * @see org.springframework.context.ConfigurableApplicationContext#close()
 */
@Override
public void destroy() {
  getServletContext().log("Destroying Spring FrameworkServlet '" + getServletName() + "'");
  // Only call close() on WebApplicationContext if locally managed...
  if (this.webApplicationContext instanceof ConfigurableApplicationContext && !this.webApplicationContextInjected) {
    ((ConfigurableApplicationContext) this.webApplicationContext).close();
  }
}

代码示例来源:origin: javax.servlet/servlet-api

/**
 * Writes an explanatory message and a stack trace
 * for a given <code>Throwable</code> exception
 * to the servlet log file, prepended by the servlet's name.
 * See {@link ServletContext#log(String, Throwable)}.
 *
 *
 * @param message         a <code>String</code> that describes
 *                the error or exception
 *
 * @param t            the <code>java.lang.Throwable</code> error
 *                 or exception
 *
 *
 */
public void log(String message, Throwable t) {
getServletContext().log(getServletName() + ": " + message, t);
}

代码示例来源:origin: Atmosphere/atmosphere

@Override
public void log(String message, Throwable t) {
  getServletContext().log(getServletName() + ": " + message, t);
}

代码示例来源:origin: Atmosphere/atmosphere

@Override
public void log(String msg) {
  getServletContext().log(getServletName() + ": " + msg);
}

代码示例来源:origin: groovy/groovy-core

/**
 * Initialize the GroovyServlet.
 *
 * @throws ServletException
 *  if this method encountered difficulties
 */
public void init(ServletConfig config) throws ServletException {
  super.init(config);
  // Set up the scripting engine
  gse = createGroovyScriptEngine();
  servletContext.log("Groovy servlet initialized on " + gse + ".");
}

代码示例来源:origin: ninjaframework/ninja

@Override
public void onStartup(Set<Class<?>> c, ServletContext servletContext) throws ServletException {
  servletContext.log("Initializing NinjaFramework in container...");
  
  servletContext.addListener(NinjaServletListener.class);
  
  servletContext.addFilter("NinjaServletFilter", NinjaServletFilter.class)
    .addMappingForUrlPatterns(null, false, "/*");
}

相关文章

微信公众号

最新文章

更多

ServletContext类方法