Search in sources :

Example 1 with LoggerLevels

use of org.springframework.boot.actuate.endpoint.LoggersEndpoint.LoggerLevels in project spring-boot by spring-projects.

the class LoggersEndpointTests method invokeShouldReturnConfigurations.

@Test
@SuppressWarnings("unchecked")
public void invokeShouldReturnConfigurations() throws Exception {
    given(getLoggingSystem().getLoggerConfigurations()).willReturn(Collections.singletonList(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG)));
    given(getLoggingSystem().getSupportedLogLevels()).willReturn(EnumSet.allOf(LogLevel.class));
    Map<String, Object> result = getEndpointBean().invoke();
    Map<String, LoggerLevels> loggers = (Map<String, LoggerLevels>) result.get("loggers");
    Set<LogLevel> levels = (Set<LogLevel>) result.get("levels");
    LoggerLevels rootLevels = loggers.get("ROOT");
    assertThat(rootLevels.getConfiguredLevel()).isNull();
    assertThat(rootLevels.getEffectiveLevel()).isEqualTo("DEBUG");
    assertThat(levels).containsExactly(LogLevel.OFF, LogLevel.FATAL, LogLevel.ERROR, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG, LogLevel.TRACE);
}
Also used : LoggerConfiguration(org.springframework.boot.logging.LoggerConfiguration) LoggerLevels(org.springframework.boot.actuate.endpoint.LoggersEndpoint.LoggerLevels) Set(java.util.Set) EnumSet(java.util.EnumSet) Map(java.util.Map) LogLevel(org.springframework.boot.logging.LogLevel) Test(org.junit.Test)

Example 2 with LoggerLevels

use of org.springframework.boot.actuate.endpoint.LoggersEndpoint.LoggerLevels in project spring-boot by spring-projects.

the class LoggersEndpointTests method invokeWhenNameSpecifiedShouldReturnLevels.

public void invokeWhenNameSpecifiedShouldReturnLevels() throws Exception {
    given(getLoggingSystem().getLoggerConfiguration("ROOT")).willReturn(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG));
    LoggerLevels levels = getEndpointBean().invoke("ROOT");
    assertThat(levels.getConfiguredLevel()).isNull();
    assertThat(levels.getEffectiveLevel()).isEqualTo("DEBUG");
}
Also used : LoggerConfiguration(org.springframework.boot.logging.LoggerConfiguration) LoggerLevels(org.springframework.boot.actuate.endpoint.LoggersEndpoint.LoggerLevels)

Aggregations

LoggerLevels (org.springframework.boot.actuate.endpoint.LoggersEndpoint.LoggerLevels)2 LoggerConfiguration (org.springframework.boot.logging.LoggerConfiguration)2 EnumSet (java.util.EnumSet)1 Map (java.util.Map)1 Set (java.util.Set)1 Test (org.junit.Test)1 LogLevel (org.springframework.boot.logging.LogLevel)1