File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
log4j-jul/src/main/java/org/apache/logging/log4j/jul Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -178,15 +178,19 @@ public void publish(final LogRecord record) {
178178 return ;
179179 }
180180
181+ // Only execute synchronized code if we really have to
181182 if (this .installAsLevelPropagator ) {
182183 synchronized (this ) {
183- @ SuppressWarnings ("resource" ) // no need to close the AutoCloseable ctx here
184- LoggerContext context = LoggerContext .getContext (false );
185- context .addConfigurationStartedListener (this );
186- propagateLogLevels (context .getConfiguration ());
187- // note: java.util.logging.LogManager.addPropertyChangeListener() could also
188- // be set here, but a call of JUL.readConfiguration() will be done on purpose
189- this .installAsLevelPropagator = false ;
184+ // Check again to make sure we still have to propagate the levels at this point
185+ if (this .installAsLevelPropagator ) {
186+ @ SuppressWarnings ("resource" ) // no need to close the AutoCloseable ctx here
187+ LoggerContext context = LoggerContext .getContext (false );
188+ context .addConfigurationStartedListener (this );
189+ propagateLogLevels (context .getConfiguration ());
190+ // note: java.util.logging.LogManager.addPropertyChangeListener() could also
191+ // be set here, but a call of JUL.readConfiguration() will be done on purpose
192+ this .installAsLevelPropagator = false ;
193+ }
190194 }
191195 }
192196
You can’t perform that action at this time.
0 commit comments