Merge branch '1.2.x'
This commit is contained in:
commit
6746a0af7b
|
@ -146,8 +146,9 @@ public class HibernateJpaAutoConfiguration extends JpaBaseConfiguration {
|
|||
vendorProperties.put(JTA_PLATFORM, new SpringJtaPlatform(
|
||||
jtaTransactionManager));
|
||||
}
|
||||
catch (NoClassDefFoundError ex) {
|
||||
// Can happen if Hibernate 4.2 is used
|
||||
catch (LinkageError ex) {
|
||||
// NoClassDefFoundError can happen if Hibernate 4.2 is used and some
|
||||
// containers (e.g. JBoss EAP 6) wraps it in the superclass LinkageError
|
||||
if (!isUsingJndi()) {
|
||||
throw new IllegalStateException("Unable to set Hibernate JTA "
|
||||
+ "platform, are you using the correct "
|
||||
|
|
|
@ -68,7 +68,7 @@ import org.springframework.util.StringUtils;
|
|||
* @author Ivan Sopov
|
||||
* @author Marcos Barbero
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = false)
|
||||
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
|
||||
public class ServerProperties implements EmbeddedServletContainerCustomizer, Ordered {
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,7 @@ public abstract class Slf4JLoggingSystem extends AbstractLoggingSystem {
|
|||
|
||||
private void configureJdkLoggingBridgeHandler() {
|
||||
try {
|
||||
if (bridgeHandlerIsAvailable()) {
|
||||
if (isBridgeHandlerAvailable()) {
|
||||
removeJdkLoggingBridgeHandler();
|
||||
SLF4JBridgeHandler.install();
|
||||
}
|
||||
|
@ -56,13 +56,13 @@ public abstract class Slf4JLoggingSystem extends AbstractLoggingSystem {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean bridgeHandlerIsAvailable() {
|
||||
protected final boolean isBridgeHandlerAvailable() {
|
||||
return ClassUtils.isPresent(BRIDGE_HANDLER, getClassLoader());
|
||||
}
|
||||
|
||||
private void removeJdkLoggingBridgeHandler() {
|
||||
try {
|
||||
if (bridgeHandlerIsAvailable()) {
|
||||
if (isBridgeHandlerAvailable()) {
|
||||
try {
|
||||
SLF4JBridgeHandler.removeHandlersForRootLogger();
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.springframework.util.StringUtils;
|
|||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.classic.joran.JoranConfigurator;
|
||||
import ch.qos.logback.classic.jul.LevelChangePropagator;
|
||||
import ch.qos.logback.classic.turbo.TurboFilter;
|
||||
import ch.qos.logback.classic.util.ContextInitializer;
|
||||
import ch.qos.logback.core.joran.spi.JoranException;
|
||||
|
@ -106,8 +107,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
|
|||
protected void loadDefaults(LoggingInitializationContext initializationContext,
|
||||
LogFile logFile) {
|
||||
LoggerContext context = getLoggerContext();
|
||||
context.stop();
|
||||
context.reset();
|
||||
stopAndReset(context);
|
||||
LogbackConfigurator configurator = new LogbackConfigurator(context);
|
||||
new DefaultLogbackConfiguration(initializationContext, logFile)
|
||||
.apply(configurator);
|
||||
|
@ -121,8 +121,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
|
|||
logFile.applyToSystemProperties();
|
||||
}
|
||||
LoggerContext loggerContext = getLoggerContext();
|
||||
loggerContext.stop();
|
||||
loggerContext.reset();
|
||||
stopAndReset(loggerContext);
|
||||
try {
|
||||
configureByResourceUrl(initializationContext, loggerContext,
|
||||
ResourceUtils.getURL(location));
|
||||
|
@ -159,6 +158,21 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
|
|||
}
|
||||
}
|
||||
|
||||
private void stopAndReset(LoggerContext loggerContext) {
|
||||
loggerContext.stop();
|
||||
loggerContext.reset();
|
||||
if (isBridgeHandlerAvailable()) {
|
||||
addLevelChangePropagator(loggerContext);
|
||||
}
|
||||
}
|
||||
|
||||
private void addLevelChangePropagator(LoggerContext loggerContext) {
|
||||
LevelChangePropagator levelChangePropagator = new LevelChangePropagator();
|
||||
levelChangePropagator.setResetJUL(true);
|
||||
levelChangePropagator.setContext(loggerContext);
|
||||
loggerContext.addListener(levelChangePropagator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanUp() {
|
||||
super.cleanUp();
|
||||
|
|
|
@ -170,6 +170,18 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
|
|||
assertTrue("Wrong output:\n" + output, output.contains("Hello world"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loggingLevelIsPropagatedToJulI() {
|
||||
this.loggingSystem.beforeInitialize();
|
||||
this.loggingSystem.initialize(null, null);
|
||||
this.loggingSystem.setLogLevel(getClass().getName(), LogLevel.DEBUG);
|
||||
java.util.logging.Logger julLogger = java.util.logging.Logger
|
||||
.getLogger(getClass().getName());
|
||||
julLogger.fine("Hello debug world");
|
||||
String output = this.output.toString().trim();
|
||||
assertTrue("Wrong output:\n" + output, output.contains("Hello debug world"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jbossLoggingIsConfiguredToUseSlf4j() {
|
||||
this.loggingSystem.beforeInitialize();
|
||||
|
|
Loading…
Reference in New Issue