add another check before we execute the synchronized code to propagate
@@ -175,8 +175,11 @@ public class Log4jBridgeHandler extends java.util.logging.Handler implements Pro
return;
}
+ // Only execute synchronized code if we really have to
if (this.installAsLevelPropagator) {
synchronized(this) {
+ // Check again to make sure we still have to propagate the levels at this point
+ if (this.installAsLevelPropagator) {
@SuppressWarnings("resource") // no need to close the AutoCloseable ctx here
LoggerContext context = LoggerContext.getContext(false);
context.addPropertyChangeListener(this);
@@ -186,6 +189,7 @@ public class Log4jBridgeHandler extends java.util.logging.Handler implements Pro
this.installAsLevelPropagator = false;
}
}
+ }
org.apache.logging.log4j.Logger log4jLogger = getLog4jLogger(record);
String msg = julFormatter.formatMessage(record); // use JUL's implementation to get real msg
