@Override public void log( Exception e, String s ) { proxy.log( e, s ); }
@Override public void log( String s, Throwable throwable ) { proxy.log( s, throwable ); }
@Override public void log( String s ) { proxy.log( s ); }
private void log(String message) { if (loggingEnabled) { filterConfig.getServletContext().log(message); } }
/** * Writes a log message after the request is processed. */ @Override protected void afterRequest(HttpServletRequest request, String message) { getServletContext().log(message); }
/** * Writes a log message before the request is processed. */ @Override protected void beforeRequest(HttpServletRequest request, String message) { getServletContext().log(message); }
/** * 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(); } }
/** * 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); } }
servletContext.log("Set web app root system property: '" + key + "' = [" + root + "]");
/** * Writes a log message after the request is processed. */ @Override protected void afterRequest(HttpServletRequest request, String message) { getServletContext().log(message); }
/** * Writes a log message before the request is processed. */ @Override protected void beforeRequest(HttpServletRequest request, String message) { getServletContext().log(message); }
@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; }
/** * 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"); } }
/** * * 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); }
/** * 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(); } }
/** * 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); }
@Override public void log(String message, Throwable t) { getServletContext().log(getServletName() + ": " + message, t); }
@Override public void log(String msg) { getServletContext().log(getServletName() + ": " + msg); }
/** * 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 + "."); }
@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, "/*"); }