List of usage examples for org.apache.commons.logging Log debug
void debug(Object message);
From source file:org.springframework.util.Log4jConfigurerTestSuite.java
public void testInitLoggingString() throws FileNotFoundException { try {/*from w w w . j a v a 2s.c om*/ Log4jConfigurer.initLogging("test/org/springframework/util/bla.properties"); fail("Exception should have been thrown, file does not exist!"); } catch (FileNotFoundException e) { // ok } Log4jConfigurer.initLogging("test/org/springframework/util/testlog4j.properties"); 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.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//from ww w . jav a 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.swordess.ldap.util.LogUtils.java
public static void debug(Log log, Object message) { if (log.isDebugEnabled()) { log.debug(message); } }
From source file:pt.webdetails.cpf.SimpleContentGenerator.java
/** * Get a map of all public methods with the Exposed annotation. * Map is not thread-safe and should be used read-only. * @param classe Class where to find methods * @param log classe's logger/*from w ww. j a v a 2 s. c o m*/ * @param lowerCase if keys should be in lower case. * @return map of all public methods with the Exposed annotation */ protected static Map<String, Method> getExposedMethods(Class<?> classe, boolean lowerCase) { HashMap<String, Method> exposedMethods = new HashMap<String, Method>(); Log log = LogFactory.getLog(classe); for (Method method : classe.getMethods()) { if (method.getAnnotation(Exposed.class) != null) { String methodKey = method.getName().toLowerCase(); if (exposedMethods.containsKey(methodKey)) { log.error("Method " + method + " differs from " + exposedMethods.get(methodKey) + " only in case and will override calls to it!!"); } log.debug("registering " + classe.getSimpleName() + "." + method.getName()); exposedMethods.put(methodKey, method); } } return exposedMethods; }