List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:org.springframework.boot.context.initializer.LoggingApplicationContextInitializerTests.java
@Test public void testAddLogPathProperty() { TestUtils.addEnviroment(this.context, "logging.config: classpath:logback-nondefault.xml", "logging.path: foo/"); this.initializer.initialize(this.context); Log logger = LogFactory.getLog(LoggingApplicationContextInitializerTests.class); logger.info("Hello world"); String output = this.outputCapture.toString().trim(); assertTrue("Wrong output:\n" + output, output.startsWith("foo/spring.log")); }
From source file:org.springframework.boot.context.listener.LoggingApplicationListenerTests.java
@Test public void testAddLogFileProperty() { EnvironmentTestUtils.addEnvironment(this.context, "logging.config: classpath:logback-nondefault.xml", "logging.file: target/foo.log"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); Log logger = LogFactory.getLog(LoggingApplicationListenerTests.class); logger.info("Hello world"); String output = this.outputCapture.toString().trim(); assertTrue("Wrong output:\n" + output, output.startsWith("target/foo.log")); }
From source file:org.springframework.boot.context.listener.LoggingApplicationListenerTests.java
@Test public void testAddLogFilePropertyWithDefault() { assertFalse(new File("target/foo.log").exists()); EnvironmentTestUtils.addEnvironment(this.context, "logging.file: target/foo.log"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); Log logger = LogFactory.getLog(LoggingApplicationListenerTests.class); logger.info("Hello world"); assertTrue(new File("target/foo.log").exists()); }
From source file:org.springframework.boot.context.listener.LoggingApplicationListenerTests.java
@Test public void testAddLogPathProperty() { EnvironmentTestUtils.addEnvironment(this.context, "logging.config: classpath:logback-nondefault.xml", "logging.path: target/foo/"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); Log logger = LogFactory.getLog(LoggingApplicationListenerTests.class); logger.info("Hello world"); String output = this.outputCapture.toString().trim(); assertTrue("Wrong output:\n" + output, output.startsWith("target/foo/spring.log")); }
From source file:org.springframework.boot.context.logging.LoggingApplicationListenerTests.java
@Test public void addLogFileProperty() { TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "logging.config=classpath:logback-nondefault.xml", "logging.file=target/foo.log"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); Log logger = LogFactory.getLog(LoggingApplicationListenerTests.class); String existingOutput = this.outputCapture.toString(); logger.info("Hello world"); String output = this.outputCapture.toString().substring(existingOutput.length()).trim(); assertThat(output).startsWith("target/foo.log"); }
From source file:org.springframework.boot.context.logging.LoggingApplicationListenerTests.java
@Test public void addLogFilePropertyWithDefault() { assertThat(new File("target/foo.log").exists()).isFalse(); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "logging.file=target/foo.log"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); Log logger = LogFactory.getLog(LoggingApplicationListenerTests.class); logger.info("Hello world"); assertThat(new File("target/foo.log").exists()).isTrue(); }
From source file:org.springframework.boot.context.logging.LoggingApplicationListenerTests.java
@Test public void addLogPathProperty() { TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "logging.config=classpath:logback-nondefault.xml", "logging.path=target/foo/"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); Log logger = LogFactory.getLog(LoggingApplicationListenerTests.class); String existingOutput = this.outputCapture.toString(); logger.info("Hello world"); String output = this.outputCapture.toString().substring(existingOutput.length()).trim(); assertThat(output).startsWith("target/foo/spring.log"); }
From source file:org.springframework.boot.legacy.context.web.NonEmbeddedWebApplicationContext.java
/** * Prepare the {@link WebApplicationContext} with the given fully loaded * {@link ServletContext}. This method is usually called from * {@link ServletContextInitializer#onStartup(ServletContext)} and is similar to the * functionality usually provided by a {@link ContextLoaderListener}. * @param servletContext the operational servlet context *///from ww w . java2 s .c om protected void prepareWebApplicationContext(ServletContext servletContext) { Object rootContext = servletContext .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (rootContext != null) { if (rootContext == this) { throw new IllegalStateException( "Cannot initialize context because there is already a root application context present - " + "check whether you have multiple ServletContextInitializers!"); } else { return; } } Log logger = LogFactory.getLog(ContextLoader.class); servletContext.log("Initializing Spring embedded WebApplicationContext"); WebApplicationContextUtils.registerWebApplicationScopes(getBeanFactory(), getServletContext()); WebApplicationContextUtils.registerEnvironmentBeans(getBeanFactory(), getServletContext()); try { servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this); 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() - getStartupDate(); logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms"); } } catch (RuntimeException ex) { logger.error("Context initialization failed", ex); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex); throw ex; } catch (Error ex) { logger.error("Context initialization failed", ex); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex); throw ex; } }
From source file:org.springframework.boot.logging.LoggingApplicationListenerTests.java
@Test public void addLogFileProperty() { EnvironmentTestUtils.addEnvironment(this.context, "logging.config: classpath:logback-nondefault.xml", "logging.file: target/foo.log"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); Log logger = LogFactory.getLog(LoggingApplicationListenerTests.class); logger.info("Hello world"); String output = this.outputCapture.toString().trim(); assertTrue("Wrong output:\n" + output, output.startsWith("target/foo.log")); }
From source file:org.springframework.boot.logging.LoggingApplicationListenerTests.java
@Test public void addLogFilePropertyWithDefault() { assertFalse(new File("target/foo.log").exists()); EnvironmentTestUtils.addEnvironment(this.context, "logging.file: target/foo.log"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); Log logger = LogFactory.getLog(LoggingApplicationListenerTests.class); logger.info("Hello world"); assertTrue(new File("target/foo.log").exists()); }