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

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

Introduction

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

Prototype

LogLevel DEBUG

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

Click Source Link

Usage

From source file:org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener.java

public ConditionEvaluationReportLoggingListener() {
    this(LogLevel.DEBUG);
}

From source file:org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener.java

private boolean isInfoOrDebug(LogLevel logLevelForReport) {
    return LogLevel.INFO.equals(logLevelForReport) || LogLevel.DEBUG.equals(logLevelForReport);
}

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  . j a 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 ww .  ja  va  2  s.  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 ww  w  .  j  a va 2s.c  o  m*/
        if (isSet(environment, "trace")) {
            this.springBootLogging = LogLevel.TRACE;
        }
    }
}

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

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

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

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

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

@Test
public void setLevel() throws Exception {
    this.loggingSystem.initialize();
    this.logger.debug("Hello");
    this.loggingSystem.setLogLevel("org.springframework.boot", LogLevel.DEBUG);
    this.logger.debug("Hello");
    assertThat(StringUtils.countOccurrencesOf(this.output.toString(), "Hello"), equalTo(1));
}

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

@Test
public void setLevel() throws Exception {
    this.loggingSystem.beforeInitialize();
    this.loggingSystem.initialize(null, null, null);
    this.logger.debug("Hello");
    this.loggingSystem.setLogLevel("org.springframework.boot", LogLevel.DEBUG);
    this.logger.debug("Hello");
    assertThat(StringUtils.countOccurrencesOf(this.output.toString(), "Hello"), equalTo(1));
}

From source file:org.springframework.boot.logging.logback.LogbackLoggingSystemTests.java

@Test
public void setLevel() throws Exception {
    this.loggingSystem.beforeInitialize();
    this.loggingSystem.initialize(this.initializationContext, null, null);
    this.logger.debug("Hello");
    this.loggingSystem.setLogLevel("org.springframework.boot", LogLevel.DEBUG);
    this.logger.debug("Hello");
    assertThat(StringUtils.countOccurrencesOf(this.output.toString(), "Hello"), equalTo(1));
}