Example usage for org.springframework.boot StartupInfoLogger StartupInfoLogger

List of usage examples for org.springframework.boot StartupInfoLogger StartupInfoLogger

Introduction

In this page you can find the example usage for org.springframework.boot StartupInfoLogger StartupInfoLogger.

Prototype

StartupInfoLogger(Class<?> sourceClass) 

Source Link

Usage

From source file:org.springframework.boot.SpringApplication.java

/**
 * Run the Spring application, creating and refreshing a new
 * {@link ApplicationContext}./*w ww .j  a va  2s  .  c o  m*/
 * @param args the application arguments (usually passed from a Java main method)
 * @return a running {@link ApplicationContext}
 */
public ConfigurableApplicationContext run(String... args) {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    ConfigurableApplicationContext context = null;
    configureHeadlessProperty();
    SpringApplicationRunListeners listeners = getRunListeners(args);
    listeners.started();
    try {
        context = doRun(listeners, args);
        stopWatch.stop();
        if (this.logStartupInfo) {
            new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), stopWatch);
        }
        return context;
    } catch (Throwable ex) {
        try {
            listeners.finished(context, ex);
            this.log.error("Application startup failed", ex);
        } finally {
            if (context != null) {
                context.close();
            }
        }
        ReflectionUtils.rethrowRuntimeException(ex);
        return context;
    }
}

From source file:org.springframework.boot.SpringApplication.java

/**
 * Called to log startup information, subclasses may override to add additional
 * logging./*from   www.ja  v  a 2 s.  c om*/
 * @param isRoot true if this application is the root of a context hierarchy
 */
protected void logStartupInfo(boolean isRoot) {
    if (isRoot) {
        new StartupInfoLogger(this.mainApplicationClass).logStarting(getApplicationLog());
    }
}

From source file:org.springframework.boot.StartUpLoggerTests.java

@Test
public void sourceClassIncluded() {
    new StartupInfoLogger(getClass()).logStarting(this.log);
    assertTrue("Wrong output: " + this.output,
            this.output.toString().contains("Starting " + getClass().getSimpleName()));
}