protected void write(String msg, Throwable throwable, int verbosity) { CharArrayWriter buf = new CharArrayWriter(); PrintWriter writer = new PrintWriter(buf); writer.println(msg); throwable.printStackTrace(writer); Throwable rootCause = null; if (throwable instanceof LifecycleException) rootCause = ((LifecycleException) throwable).getCause(); else if (throwable instanceof ServletException) rootCause = ((ServletException) throwable).getRootCause(); if (rootCause != null) { writer.println("----- Root Cause -----"); rootCause.printStackTrace(writer); } write(buf.toString(), verbosity); }
private void stopCacheManager(WebModule webModule) { ServletContext ctxt = webModule.getServletContext(); CacheManager cm = (CacheManager)ctxt.getAttribute( CacheManager.CACHE_MANAGER_ATTR_NAME); if (cm != null) { try { cm.stop(); if (_logger.isLoggable(Level.FINE)) { _logger.fine("Cache Manager stopped"); } ctxt.removeAttribute(CacheManager.CACHE_MANAGER_ATTR_NAME); } catch (LifecycleException ee) { _logger.log(Level.WARNING, ee.getMessage(), ee.getCause()); } } }
/** * Writes an explanatory message and a stack trace for a given * <code>Throwable</code> exception to the servlet log file. The name * and type of the servlet log file is specific to the servlet container, * usually an event log. This message will be logged unconditionally. * * @param msg A <code>String</code> that describes the error or * exception * @param throwable The <code>Throwable</code> error or exception */ public void log(String msg, Throwable throwable) { msg = neutralizeForLog(msg); CharArrayWriter buf = new CharArrayWriter(); PrintWriter writer = new PrintWriter(buf); writer.println(msg); throwable.printStackTrace(writer); Throwable rootCause = null; if (throwable instanceof LifecycleException) rootCause = ((LifecycleException) throwable).getCause(); else if (throwable instanceof ServletException) rootCause = ((ServletException) throwable).getRootCause(); if (rootCause != null) { writer.println("----- Root Cause -----"); rootCause.printStackTrace(writer); } log(buf.toString()); }
private void startCacheManager(WebModule webModule) { SunWebApp bean = webModule.getIasWebAppConfigBean(); // Configure the cache, cache-mapping and other settings if (bean != null) { CacheManager cm = null; try { cm = CacheModule.configureResponseCache(webModule, bean); } catch (Exception ee) { _logger.log(Level.WARNING, "webmodule.listener.cachemgrException", ee); } if (cm != null) { try { // first start the CacheManager, if enabled cm.start(); if (_logger.isLoggable(Level.FINE)) { _logger.fine("Cache Manager started"); } // set this manager as a context attribute so that // caching filters/tags can find it ServletContext ctxt = webModule.getServletContext(); ctxt.setAttribute(CacheManager.CACHE_MANAGER_ATTR_NAME, cm); } catch (LifecycleException ee) { _logger.log(Level.WARNING, ee.getMessage(), ee.getCause()); } } } }