Example usage for org.springframework.boot.logging LogLevel TRACE

List of usage examples for org.springframework.boot.logging LogLevel TRACE

Introduction

In this page you can find the example usage for org.springframework.boot.logging LogLevel TRACE.

Prototype

LogLevel TRACE

To view the source code for org.springframework.boot.logging LogLevel TRACE.

Click Source Link

Usage

From source file:org.springframework.boot.context.initializer.LoggingApplicationContextInitializer.java

/**
 * Initialize the logging system according to preferences expressed through the
 * {@link Environment} and the classpath.
 *//*  w w  w.  ja  v  a2s . c  om*/
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {

    ConfigurableEnvironment environment = applicationContext.getEnvironment();

    if (this.parseArgs && this.springBootLogging == null) {
        if (environment.containsProperty("debug")) {
            this.springBootLogging = LogLevel.DEBUG;
        }
        if (environment.containsProperty("trace")) {
            this.springBootLogging = LogLevel.TRACE;
        }
    }

    for (Map.Entry<String, String> mapping : ENVIRONMENT_SYSTEM_PROPERTY_MAPPING.entrySet()) {
        if (environment.containsProperty(mapping.getKey())) {
            System.setProperty(mapping.getValue(), environment.getProperty(mapping.getKey()));
        }
    }

    LoggingSystem system = LoggingSystem.get(applicationContext.getClassLoader());

    // User specified configuration
    if (environment.containsProperty("logging.config")) {
        String value = environment.getProperty("logging.config");
        try {
            ResourceUtils.getURL(value).openStream().close();
            system.initialize(value);
            return;
        } catch (Exception ex) {
            // Swallow exception and continue
        }
        this.logger.warn("Logging environment value '" + value + "' cannot be opened and will be ignored");
    }

    system.initialize();
    if (this.springBootLogging != null) {
        initializeLogLevel(system, this.springBootLogging);
    }
}

From source file:org.springframework.boot.context.listener.LoggingApplicationListener.java

/**
 * Initialize the logging system according to preferences expressed through the
 * {@link Environment} and the classpath.
 *///from   w w  w . jav a2s .c o m
protected void initialize(ConfigurableEnvironment environment, ClassLoader classLoader) {

    if (this.parseArgs && this.springBootLogging == null) {
        if (environment.containsProperty("debug")) {
            this.springBootLogging = LogLevel.DEBUG;
        }
        if (environment.containsProperty("trace")) {
            this.springBootLogging = LogLevel.TRACE;
        }
    }

    boolean environmentChanged = false;
    for (Map.Entry<String, String> mapping : ENVIRONMENT_SYSTEM_PROPERTY_MAPPING.entrySet()) {
        if (environment.containsProperty(mapping.getKey())) {
            System.setProperty(mapping.getValue(), environment.getProperty(mapping.getKey()));
            environmentChanged = true;
        }
    }

    LoggingSystem system = LoggingSystem.get(classLoader);

    if (environmentChanged) {
        // Re-initialize the defaults in case the Environment changed
        system.beforeInitialize();
    }
    // User specified configuration
    if (environment.containsProperty("logging.config")) {
        String value = environment.getProperty("logging.config");
        try {
            ResourceUtils.getURL(value).openStream().close();
            system.initialize(value);
            return;
        } catch (Exception ex) {
            // Swallow exception and continue
        }
        this.logger.warn("Logging environment value '" + value + "' cannot be opened and will be ignored");
    }

    system.initialize();
    if (this.springBootLogging != null) {
        initializeLogLevel(system, this.springBootLogging);
    }
}

From source file:org.springframework.boot.context.logging.LoggingApplicationListener.java

private void initializeEarlyLoggingLevel(ConfigurableEnvironment environment) {
    if (this.parseArgs && this.springBootLogging == null) {
        if (isSet(environment, "debug")) {
            this.springBootLogging = LogLevel.DEBUG;
        }/*from  w  w w . j a v a2 s . c o  m*/
        if (isSet(environment, "trace")) {
            this.springBootLogging = LogLevel.TRACE;
        }
    }
}

From source file:org.springframework.boot.logging.DeferredLog.java

@Override
public void trace(Object message) {
    log(LogLevel.TRACE, message, null);
}

From source file:org.springframework.boot.logging.DeferredLog.java

@Override
public void trace(Object message, Throwable t) {
    log(LogLevel.TRACE, message, t);
}

From source file:org.springframework.boot.logging.LoggingApplicationListener.java

private void initializeEarlyLoggingLevel(ConfigurableEnvironment environment) {
    if (this.parseArgs && this.springBootLogging == null) {
        if (environment.containsProperty("debug")) {
            this.springBootLogging = LogLevel.DEBUG;
        }//from w w w. j  av  a2 s. c  om
        if (environment.containsProperty("trace")) {
            this.springBootLogging = LogLevel.TRACE;
        }
    }
}