List of usage examples for org.apache.commons.logging Log isInfoEnabled
boolean isInfoEnabled();
From source file:org.apache.ojb.broker.util.logging.CommonsLoggerImpl.java
/** * @see org.apache.ojb.broker.util.logging.Logger#isEnabledFor(int) *///from ww w.jav a 2 s.c o m public boolean isEnabledFor(int priority) { Log commonsLog = getLog(); switch (priority) { case Logger.DEBUG: return commonsLog.isDebugEnabled(); case Logger.INFO: return commonsLog.isInfoEnabled(); case Logger.WARN: return commonsLog.isWarnEnabled(); case Logger.ERROR: return commonsLog.isErrorEnabled(); case Logger.FATAL: return commonsLog.isFatalEnabled(); } return false; }
From source file:org.apache.tiles.access.TilesAccess.java
/** * Configures the container to be used in the application. * * @param context The Tiles application context object to use. * @param container The container object to set. * @param key The key under which the container will be stored. * @throws TilesAccessException If something goes wrong during manipulation of the * context.// ww w . ja va2 s . c om * @since 2.1.2 */ public static void setContainer(TilesApplicationContext context, TilesContainer container, String key) { Log log = LogFactory.getLog(TilesAccess.class); if (key == null) { key = CONTAINER_ATTRIBUTE; } if (container == null) { if (log.isInfoEnabled()) { log.info("Removing TilesContext for context: " + context.getClass().getName()); } context.getApplicationScope().remove(key); } if (container != null && log.isInfoEnabled()) { log.info("Publishing TilesContext for context: " + context.getClass().getName()); } context.getApplicationScope().put(key, container); }
From source file:org.apache.tiles.access.TilesAccess.java
/** * Configures the default container to be used in the application. * * @param context The (application) context object to use. * @param container The container object to set. * @throws TilesAccessException If something goes wrong during manipulation of the * context.//ww w. j ava2 s. c o m * @deprecated Use {@link #setContainer(TilesApplicationContext, TilesContainer)}. */ @Deprecated public static void setContainer(Object context, TilesContainer container) { Log log = LogFactory.getLog(TilesAccess.class); if (container == null) { if (log.isInfoEnabled()) { log.info("Removing TilesContext for context: " + context.getClass().getName()); } removeAttribute(context, CONTAINER_ATTRIBUTE); } if (container != null && log.isInfoEnabled()) { log.info("Publishing TilesContext for context: " + context.getClass().getName()); } setAttribute(context, CONTAINER_ATTRIBUTE, container); }
From source file:org.apache.tiles.context.AbstractTilesApplicationContextFactory.java
/** * Creates the Tiles application context factory. * * @param preliminaryContext The preliminary {@link TilesApplicationContext} * that allows access to the initialization parameters. * @return The factory.// w w w . j av a 2s . c o m * @since 2.1.1 */ public static AbstractTilesApplicationContextFactory createFactory(TilesApplicationContext preliminaryContext) { Log log = LogFactory.getLog(AbstractTilesApplicationContextFactory.class); AbstractTilesApplicationContextFactory retValue; if (log.isInfoEnabled()) { log.info("Initializing Tiles2 application context. . ."); } Map<String, String> params = preliminaryContext.getInitParams(); String className = params.get(APPLICATION_CONTEXT_FACTORY_INIT_PARAM); if (className != null) { retValue = (AbstractTilesApplicationContextFactory) ClassUtil.instantiate(className); } else { retValue = new ChainedTilesApplicationContextFactory(); } if (retValue instanceof Initializable) { ((Initializable) retValue).init(params); } if (log.isInfoEnabled()) { log.info("Finished initializing Tiles2 application context."); } return retValue; }
From source file:org.apache.tiles.jsp.context.JspUtil.java
/** * Configures the container to be used in the application. * * @param context The page context object to use. * @param container The container object to set. * @param key The key under which the container will be stored. * @since 2.1.2/*from ww w . java2 s . c o m*/ */ public static void setContainer(PageContext context, TilesContainer container, String key) { Log log = LogFactory.getLog(ServletUtil.class); if (key == null) { key = TilesAccess.CONTAINER_ATTRIBUTE; } if (container == null) { if (log.isInfoEnabled()) { log.info("Removing TilesContext for context: " + context.getClass().getName()); } context.removeAttribute(key, PageContext.APPLICATION_SCOPE); } if (container != null && log.isInfoEnabled()) { log.info("Publishing TilesContext for context: " + context.getClass().getName()); } context.setAttribute(key, container, PageContext.APPLICATION_SCOPE); }
From source file:org.apache.tiles.servlet.context.ServletUtil.java
/** * Configures the container to be used in the application. * * @param context The servlet context object to use. * @param container The container object to set. * @param key The key under which the container will be stored. * @since 2.1.2//from w w w . j a v a 2 s . c o m */ public static void setContainer(ServletContext context, TilesContainer container, String key) { Log log = LogFactory.getLog(ServletUtil.class); if (key == null) { key = TilesAccess.CONTAINER_ATTRIBUTE; } if (container == null) { if (log.isInfoEnabled()) { log.info("Removing TilesContext for context: " + context.getClass().getName()); } context.removeAttribute(key); } if (container != null && log.isInfoEnabled()) { log.info("Publishing TilesContext for context: " + context.getClass().getName()); } context.setAttribute(key, container); }
From source file:org.atomserver.AtomServer.java
private void log500Error(Throwable e, Abdera abdera, RequestContext request) { if (errlog != null) { Log http500log = errlog.getLog(); if (http500log.isInfoEnabled()) { try { http500log.info(/* www . ja v a2s. c o m*/ "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); http500log.info("==> 500 ERROR occurred for {" + request.getUri() + "} Type:: " + e.getClass().getName() + " Reason:: " + e.getMessage()); http500log.error("500 Error:: ", e); http500log.info("METHOD:: " + request.getMethod()); if (request.getPrincipal() != null) { http500log.info("PRINCIPAL:: " + request.getPrincipal().getName()); } http500log.info("HEADERS:: "); String[] headerNames = request.getHeaderNames(); if (headerNames != null) { for (int ii = 0; ii < headerNames.length; ii++) { http500log .info("Header(" + headerNames[ii] + ")= " + request.getHeader(headerNames[ii])); } } http500log.info("PARAMETERS:: "); String[] paramNames = request.getParameterNames(); if (paramNames != null) { for (int ii = 0; ii < paramNames.length; ii++) { http500log.info( "Parameter(" + paramNames[ii] + ")= " + request.getParameter(paramNames[ii])); } } if (request instanceof HttpServletRequestContext) { HttpServletRequestContext httpRequest = (HttpServletRequestContext) request; javax.servlet.http.HttpServletRequest servletRequest = httpRequest.getRequest(); if (servletRequest != null) { http500log.info("QUERY STRING::" + servletRequest.getQueryString()); http500log.info("AUTH TYPE:: " + servletRequest.getAuthType()); http500log.info("REMOTE USER:: " + servletRequest.getRemoteUser()); http500log.info("REMOTE ADDR:: " + servletRequest.getRemoteAddr()); http500log.info("REMOTE HOST:: " + servletRequest.getRemoteHost()); } } http500log.info("BODY:: "); if (request.getDocument() != null) { java.io.StringWriter stringWriter = new java.io.StringWriter(); request.getDocument().writeTo(abdera.getWriterFactory().getWriter("PrettyXML"), stringWriter); //http500log.info( "\n" + stringWriter.toString() ); String requestString = stringWriter.toString(); if (requestString != null && requestString.length() > MAX_REQ_BODY_DUMP) { requestString = requestString.substring(0, (MAX_REQ_BODY_DUMP - 1)); } http500log.info("\n" + requestString); } } catch (Exception ee) { } } } }
From source file:org.cloudata.core.common.util.ReflectionUtils.java
/** * Log the current thread stacks at INFO level. * @param log the logger that logs the stack trace * @param title a descriptive title for the call stacks * @param minInterval the minimum time from the last */// w ww. ja va 2s. c om public static synchronized void logThreadInfo(Log log, String title, long minInterval) { if (log.isInfoEnabled()) { long now = System.currentTimeMillis(); if (now - previousLogTime >= minInterval * 1000) { previousLogTime = now; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); printThreadInfo(new PrintWriter(buffer), title); log.info(buffer.toString()); } } }
From source file:org.danann.cernunnos.runtime.Main.java
public static void main(String[] args) { Log log = LogFactory.getLog(ScriptRunner.class); // Put some whitespace between the command and the output... System.out.println(""); // Register custom protocol handlers... try {//from w ww.ja v a 2 s. com URL.setURLStreamHandlerFactory(new URLStreamHandlerFactoryImpl()); } catch (Throwable t) { log.warn("Cernunnos was unable to register a URLStreamHandlerFactory. " + "Custom URL protocols may not work properly (e.g. classpath://, c:/). " + "See stack trace below.", t); } // Establish CRN_HOME... String crnHome = System.getenv("CRN_HOME"); if (crnHome == null) { if (log.isDebugEnabled()) { log.debug("The CRN_HOME environment variable is not defined; " + "this is completely normal for embedded applications " + "of Cernunnos."); } } // Look at the specified script: might it be in the bin/ directory? String location = args[0]; try { // This is how ScriptRunner will attempt to locate the script file... URL u = new URL(new File(".").toURI().toURL(), location); if (u.getProtocol().equals("file")) { // We know the specified resource is a local file; is it either // (1) absolute or (2) relative to the directory where Java is // executing? if (!new File(u.toURI()).exists() && crnHome != null) { // No. And what's more, 'CRN_HOME' is defined. In this case // let's see if the specified script *is* present in the bin/ // directory. StringBuilder path = new StringBuilder(); path.append(crnHome).append(File.separator).append("bin").append(File.separator) .append(location); File f = new File(path.toString()); if (f.exists()) { // The user is specifying a Cernunnos script in the bin/ directory... location = f.toURI().toURL().toExternalForm(); if (log.isInfoEnabled()) { log.info("Resolving the specified Cernunnos document " + "to a file in the CRN_HOME/bin directory: " + location); } } } } } catch (Throwable t) { // Just let this pass -- genuine issues will be caught & reported shortly... } // Analyze the command-line arguments... RuntimeRequestResponse req = new RuntimeRequestResponse(); switch (args.length) { case 0: // No file provided, can't continue... System.out.println("Usage:\n\n\t>crn [script_name] [arguments]"); System.exit(0); break; default: for (int i = 1; i < args.length; i++) { req.setAttribute("$" + i, args[i]); } break; } ScriptRunner runner = new ScriptRunner(); runner.run(location, req); }
From source file:org.easyrec.utils.io.autoimport.AutoImportUtils.java
public static void logSkippedLine(Log logger, int lineCounter, String line, String message) { if (logger.isInfoEnabled()) { StringBuilder s = new StringBuilder("skipped data line["); s.append(lineCounter);// ww w .j a va 2 s. c o m s.append("] '"); s.append(line); s.append("', "); s.append(message); logger.info(s.toString()); } }