diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java index bbcc94c45d..27626e512f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java @@ -51,6 +51,7 @@ import org.springframework.boot.CommandLineRunner; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.core.Ordered; +import org.springframework.core.log.LogMessage; import org.springframework.util.Assert; import org.springframework.util.PatternMatchUtils; import org.springframework.util.StringUtils; @@ -158,9 +159,7 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner, Ordered, if (StringUtils.hasText(this.jobNames)) { String[] jobsToRun = this.jobNames.split(","); if (!PatternMatchUtils.simpleMatch(jobsToRun, job.getName())) { - if (logger.isDebugEnabled()) { - logger.debug("Skipped job: " + job.getName()); - } + logger.debug(LogMessage.format("Skipped job: %s", job.getName())); continue; } } @@ -180,9 +179,7 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner, Ordered, execute(job, jobParameters); } catch (NoSuchJobException ex) { - if (logger.isDebugEnabled()) { - logger.debug("No job found in registry for job name: " + jobName); - } + logger.debug(LogMessage.format("No job found in registry for job name: %s", jobName)); } } } diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java index 5666867497..21cdd21119 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java @@ -29,6 +29,7 @@ import java.util.regex.Pattern; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.core.log.LogMessage; import org.springframework.util.Base64Utils; /** @@ -68,9 +69,7 @@ class Connection { this.inputStream = new ConnectionInputStream(inputStream); this.outputStream = new ConnectionOutputStream(outputStream); this.header = this.inputStream.readHeader(); - if (logger.isDebugEnabled()) { - logger.debug("Established livereload connection [" + this.header + "]"); - } + logger.debug(LogMessage.format("Established livereload connection [%s]", this.header)); } /** @@ -109,9 +108,7 @@ class Connection { throw new ConnectionClosedException(); } else if (frame.getType() == Frame.Type.TEXT) { - if (logger.isDebugEnabled()) { - logger.debug("Received LiveReload text frame " + frame); - } + logger.debug(LogMessage.format("Received LiveReload text frame %s", frame)); } else { throw new IOException("Unexpected Frame Type " + frame.getType()); diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/LiveReloadServer.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/LiveReloadServer.java index 08157b6f46..8c79a36c8d 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/LiveReloadServer.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/LiveReloadServer.java @@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.core.log.LogMessage; import org.springframework.util.Assert; /** @@ -109,9 +110,7 @@ public class LiveReloadServer { public int start() throws IOException { synchronized (this.monitor) { Assert.state(!isStarted(), "Server already started"); - if (logger.isDebugEnabled()) { - logger.debug("Starting live reload server on port " + this.port); - } + logger.debug(LogMessage.format("Starting live reload server on port %s", this.port)); this.serverSocket = new ServerSocket(this.port); int localPort = this.serverSocket.getLocalPort(); this.listenThread = this.threadFactory.newThread(this::acceptConnections); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java index 5f4e4b233e..cd15fc3c20 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java @@ -30,6 +30,7 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.EnvironmentAware; import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.io.support.SpringFactoriesLoader; +import org.springframework.core.log.LogMessage; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.ReflectionUtils; @@ -113,9 +114,7 @@ final class FailureAnalyzers implements SpringBootExceptionReporter { } } catch (Throwable ex) { - if (logger.isDebugEnabled()) { - logger.debug("FailureAnalyzer " + analyzer + " failed", ex); - } + logger.debug(LogMessage.format("FailureAnalyzer %s failed", analyzer), ex); } } return null;