List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:org.springframework.web.context.ContextLoader.java
/** * Initialize Spring's web application context for the given servlet context, * using the application context provided at construction time, or creating a new one * according to the "{@link #CONTEXT_CLASS_PARAM contextClass}" and * "{@link #CONFIG_LOCATION_PARAM contextConfigLocation}" context-params. * @param servletContext current servlet context * @return the new WebApplicationContext * @see #ContextLoader(WebApplicationContext) * @see #CONTEXT_CLASS_PARAM/* w w w . ja va 2s . c o m*/ * @see #CONFIG_LOCATION_PARAM */ public WebApplicationContext initWebApplicationContext(ServletContext servletContext) { if (servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null) { throw new IllegalStateException( "Cannot initialize context because there is already a root application context present - " + "check whether you have multiple ContextLoader* definitions in your web.xml!"); } Log logger = LogFactory.getLog(ContextLoader.class); servletContext.log("Initializing Spring root WebApplicationContext"); if (logger.isInfoEnabled()) { logger.info("Root WebApplicationContext: initialization started"); } long startTime = System.currentTimeMillis(); try { // Store context in local instance variable, to guarantee that // it is available on ServletContext shutdown. if (this.context == null) { this.context = createWebApplicationContext(servletContext); } if (this.context instanceof ConfigurableWebApplicationContext) { ConfigurableWebApplicationContext cwac = (ConfigurableWebApplicationContext) this.context; if (!cwac.isActive()) { // The context has not yet been refreshed -> provide services such as // setting the parent context, setting the application context id, etc if (cwac.getParent() == null) { // The context instance was injected without an explicit parent -> // determine parent for root web application context, if any. ApplicationContext parent = loadParentContext(servletContext); cwac.setParent(parent); } configureAndRefreshWebApplicationContext(cwac, servletContext); } } servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context); ClassLoader ccl = Thread.currentThread().getContextClassLoader(); if (ccl == ContextLoader.class.getClassLoader()) { currentContext = this.context; } else if (ccl != null) { currentContextPerThread.put(ccl, this.context); } if (logger.isDebugEnabled()) { logger.debug("Published root WebApplicationContext as ServletContext attribute with name [" + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]"); } if (logger.isInfoEnabled()) { long elapsedTime = System.currentTimeMillis() - startTime; logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms"); } return this.context; } catch (RuntimeException ex) { logger.error("Context initialization failed", ex); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex); throw ex; } catch (Error err) { logger.error("Context initialization failed", err); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err); throw err; } }
From source file:org.springframework.web.util.Log4jWebConfigurerTests.java
private void assertLogOutput() { Log log = LogFactory.getLog(this.getClass()); log.debug("debug"); log.info("info"); log.warn("warn"); log.error("error"); log.fatal("fatal"); assertTrue(MockLog4jAppender.loggingStrings.contains("debug")); assertTrue(MockLog4jAppender.loggingStrings.contains("info")); assertTrue(MockLog4jAppender.loggingStrings.contains("warn")); assertTrue(MockLog4jAppender.loggingStrings.contains("error")); assertTrue(MockLog4jAppender.loggingStrings.contains("fatal")); }
From source file:org.springframework.xd.dirt.launcher.AbstractContainerLauncher.java
protected void logContainerInfo(Log logger, XDContainer container) { if (logger.isInfoEnabled()) { StringBuilder runtimeInfo = new StringBuilder(); runtimeInfo.append(this.getRuntimeInfo(container)); if (container.isJmxEnabled()) { runtimeInfo.append(// w w w . j a va2 s.com String.format("\nMBean Server: http://localhost:%d/jolokia/", container.getJmxPort())); } else { runtimeInfo.append(" JMX is disabled for XD components"); } runtimeInfo.append(logXDEnvironment(container)); logger.info(BannerUtils.displayBanner(container.getJvmName(), runtimeInfo.toString())); } }
From source file:org.springframework.xd.dirt.launcher.LocalContainerLauncher.java
@Override protected void logContainerInfo(Log logger, XDContainer container, ContainerOptions options) { if (logger.isInfoEnabled()) { final StringBuilder runtimeInfo = new StringBuilder(); runtimeInfo.append("Using local mode"); if (!options.isJmxEnabled()) { runtimeInfo.append(" JMX is disabled for XD components"); } else {/*from w w w .j av a 2s .c om*/ runtimeInfo.append(String.format(" JMX port: %d", options.getJmxPort())); } logger.info(BannerUtils.displayBanner(container.getJvmName(), runtimeInfo.toString())); } }
From source file:org.springframework.xd.dirt.launcher.RabbitContainerLauncher.java
@Override public void logContainerInfo(Log logger, XDContainer container, ContainerOptions options) { if (logger.isInfoEnabled()) { final StringBuilder runtimeInfo = new StringBuilder(); runtimeInfo.append(String.format("Using RabbitMQ at %s (virtual host: %s) on port: %d ", this.connectionFactory.getHost(), this.connectionFactory.getVirtualHost(), this.connectionFactory.getPort())); if (options.isJmxEnabled()) { runtimeInfo.append(String.format(" JMX port: %d", options.getJmxPort())); } else {//w ww .j av a2s . c o m runtimeInfo.append(" JMX is disabled for XD components"); } logger.info(BannerUtils.displayBanner(container.getJvmName(), runtimeInfo.toString())); } }
From source file:org.swordess.ldap.util.LogUtils.java
public static void info(Log log, Object message) { if (log.isInfoEnabled()) { log.info(message); } }
From source file:org.talend.esb.monitoring.hq.HypericUtils.java
public static void logInfo(final Log log, final Object o1, final Object... info) { if (!log.isInfoEnabled()) { return;/*from w ww . j ava 2 s. c o m*/ } if (info.length == 0) { log.info(o1.toString()); return; } final StringBuilder sb = new StringBuilder(o1.toString()); for (final Object o : info) { sb.append(o.toString()); } log.info(sb.toString()); }
From source file:org.taverna.server.master.utils.JCECheck.java
/** * Write a message to the log that says whether an unlimited strength * {@linkplain #Cipher cipher} is present. This is the official proxy for * whether the unlimited strength JCE policy files have been installed; if * absent, the message is logged as a warning, otherwise it is just * informational.// w w w.ja v a 2 s.c om */ @PostConstruct public void checkForUnlimitedJCE() { Log log = getLog("Taverna.Server.Utils"); try { if (getMaxAllowedKeyLength("AES") < MAX_VALUE) log.warn("maximum key length very short; unlimited " + "strength JCE policy files maybe missing"); else log.info("unlimited strength JCE policy in place"); } catch (GeneralSecurityException e) { log.warn("problem computing key length limits!", e); } }
From source file:org.usrz.libs.logging.LevelDebugTest.java
@Test public void testCommonsLogging() { final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(this.getClass()); logger.trace("Foobar TRACE"); AppenderForTests.hasNoLastEvent("at Trace level"); assertFalse(logger.isTraceEnabled()); logger.debug("Foobar DEBUG"); AppenderForTests.hasLastEvent("at Debug level"); assertTrue(logger.isDebugEnabled()); logger.info("Foobar INFO"); AppenderForTests.hasLastEvent("at Info level"); assertTrue(logger.isInfoEnabled());/*from w ww . j a v a 2 s. c o m*/ logger.warn("Foobar WARN"); AppenderForTests.hasLastEvent("at Warn level"); assertTrue(logger.isWarnEnabled()); logger.error("Foobar ERROR"); AppenderForTests.hasLastEvent("at Error level"); assertTrue(logger.isErrorEnabled()); logger.fatal("Foobar FATAL"); AppenderForTests.hasLastEvent("at Fatal level"); assertTrue(logger.isFatalEnabled()); }
From source file:org.usrz.libs.logging.LevelErrorTest.java
@Test public void testCommonsLogging() { final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(this.getClass()); logger.trace("Foobar TRACE"); AppenderForTests.hasNoLastEvent("at Trace level"); assertFalse(logger.isTraceEnabled()); logger.debug("Foobar DEBUG"); AppenderForTests.hasNoLastEvent("at Debug level"); assertFalse(logger.isDebugEnabled()); logger.info("Foobar INFO"); AppenderForTests.hasNoLastEvent("at Info level"); assertFalse(logger.isInfoEnabled()); logger.warn("Foobar WARN"); AppenderForTests.hasNoLastEvent("at Warn level"); assertFalse(logger.isWarnEnabled()); logger.error("Foobar ERROR"); AppenderForTests.hasLastEvent("at Error level"); assertTrue(logger.isErrorEnabled()); logger.fatal("Foobar FATAL"); AppenderForTests.hasLastEvent("at Fatal level"); assertTrue(logger.isFatalEnabled()); }