pull/4069/head
Phillip Webb 9 years ago
parent cad2666522
commit acde5407e8

@ -142,7 +142,8 @@ public class MongoDataAutoConfiguration implements BeanClassLoaderAware {
context.setInitialEntitySet(getInitialEntitySet(beanFactory));
Class<?> strategyClass = this.properties.getFieldNamingStrategy();
if (strategyClass != null) {
context.setFieldNamingStrategy((FieldNamingStrategy) BeanUtils.instantiate(strategyClass));
context.setFieldNamingStrategy((FieldNamingStrategy) BeanUtils
.instantiate(strategyClass));
}
return context;
}

@ -86,8 +86,8 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
@Override
protected String[] getStandardConfigLocations() {
return new String[] { "logback-test.groovy", "logback-test.xml", "logback.groovy",
"logback.xml" };
return new String[] { "logback-test.groovy", "logback-test.xml",
"logback.groovy", "logback.xml" };
}
@Override
@ -110,9 +110,8 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
LoggerContext context = getLoggerContext();
stopAndReset(context);
LogbackConfigurator configurator = new LogbackConfigurator(context);
context.putProperty("LOG_LEVEL_PATTERN",
initializationContext.getEnvironment().resolvePlaceholders(
"${logging.pattern.level:${LOG_LEVEL_PATTERN:%5p}}"));
context.putProperty("LOG_LEVEL_PATTERN", initializationContext.getEnvironment()
.resolvePlaceholders("${logging.pattern.level:${LOG_LEVEL_PATTERN:%5p}}"));
new DefaultLogbackConfiguration(initializationContext, logFile)
.apply(configurator);
}
@ -131,8 +130,8 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
ResourceUtils.getURL(location));
}
catch (Exception ex) {
throw new IllegalStateException(
"Could not initialize Logback logging from " + location, ex);
throw new IllegalStateException("Could not initialize Logback logging from "
+ location, ex);
}
List<Status> statuses = loggerContext.getStatusManager().getCopyOfStatusList();
StringBuilder errors = new StringBuilder();
@ -143,8 +142,8 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
}
}
if (errors.length() > 0) {
throw new IllegalStateException(
"Logback configuration error " + "detected: \n" + errors);
throw new IllegalStateException("Logback configuration error "
+ "detected: \n" + errors);
}
}
@ -201,21 +200,20 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
private ch.qos.logback.classic.Logger getLogger(String name) {
LoggerContext factory = getLoggerContext();
return factory
.getLogger(StringUtils.isEmpty(name) ? Logger.ROOT_LOGGER_NAME : name);
return factory.getLogger(StringUtils.isEmpty(name) ? Logger.ROOT_LOGGER_NAME
: name);
}
private LoggerContext getLoggerContext() {
ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory();
Assert.isInstanceOf(LoggerContext.class, factory,
String.format(
"LoggerFactory is not a Logback LoggerContext but Logback is on "
+ "the classpath. Either remove Logback or the competing "
+ "implementation (%s loaded from %s). If you are using "
+ "Weblogic you will need to add 'org.slf4j' to "
+ "prefer-application-packages in WEB-INF/weblogic.xml",
factory.getClass(), getLocation(factory)));
Assert.isInstanceOf(LoggerContext.class, factory, String.format(
"LoggerFactory is not a Logback LoggerContext but Logback is on "
+ "the classpath. Either remove Logback or the competing "
+ "implementation (%s loaded from %s). If you are using "
+ "Weblogic you will need to add 'org.slf4j' to "
+ "prefer-application-packages in WEB-INF/weblogic.xml",
factory.getClass(), getLocation(factory)));
return (LoggerContext) factory;
}

@ -16,16 +16,6 @@
package org.springframework.boot.logging.logback;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileReader;
import java.util.logging.Handler;
@ -54,6 +44,16 @@ import org.springframework.util.StringUtils;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
* Tests for {@link LogbackLoggingSystem}.
*

Loading…
Cancel
Save