Skip to content

Commit 429eec0

Browse files
committed
Merge pull request #18604 from wycm
* pr/18604: Optimize debug level logs Closes gh-18604
2 parents 91f4300 + 681a94b commit 429eec0

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ private void executeLocalJobs(JobParameters jobParameters) throws JobExecutionEx
174174
if (StringUtils.hasText(this.jobNames)) {
175175
String[] jobsToRun = this.jobNames.split(",");
176176
if (!PatternMatchUtils.simpleMatch(jobsToRun, job.getName())) {
177-
logger.debug("Skipped job: " + job.getName());
177+
if (logger.isDebugEnabled()) {
178+
logger.debug("Skipped job: " + job.getName());
179+
}
178180
continue;
179181
}
180182
}
@@ -194,7 +196,9 @@ private void executeRegisteredJobs(JobParameters jobParameters) throws JobExecut
194196
execute(job, jobParameters);
195197
}
196198
catch (NoSuchJobException ex) {
197-
logger.debug("No job found in registry for job name: " + jobName);
199+
if (logger.isDebugEnabled()) {
200+
logger.debug("No job found in registry for job name: " + jobName);
201+
}
198202
}
199203
}
200204
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedConfigurationFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public Configuration createConfiguration() {
6363
TransportConfiguration transportConfiguration = new TransportConfiguration(InVMAcceptorFactory.class.getName(),
6464
this.properties.generateTransportParameters());
6565
configuration.getAcceptorConfigurations().add(transportConfiguration);
66-
if (this.properties.isDefaultClusterPassword()) {
66+
if (this.properties.isDefaultClusterPassword() && logger.isDebugEnabled()) {
6767
logger.debug("Using default Artemis cluster password: " + this.properties.getClusterPassword());
6868
}
6969
configuration.setClusterPassword(this.properties.getClusterPassword());

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ class Connection {
6868
this.inputStream = new ConnectionInputStream(inputStream);
6969
this.outputStream = new ConnectionOutputStream(outputStream);
7070
this.header = this.inputStream.readHeader();
71-
logger.debug("Established livereload connection [" + this.header + "]");
71+
if (logger.isDebugEnabled()) {
72+
logger.debug("Established livereload connection [" + this.header + "]");
73+
}
7274
}
7375

7476
/**
@@ -107,7 +109,9 @@ else if (frame.getType() == Frame.Type.CLOSE) {
107109
throw new ConnectionClosedException();
108110
}
109111
else if (frame.getType() == Frame.Type.TEXT) {
110-
logger.debug("Received LiveReload text frame " + frame);
112+
if (logger.isDebugEnabled()) {
113+
logger.debug("Received LiveReload text frame " + frame);
114+
}
111115
}
112116
else {
113117
throw new IOException("Unexpected Frame Type " + frame.getType());

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/LiveReloadServer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ public LiveReloadServer(int port, ThreadFactory threadFactory) {
109109
public int start() throws IOException {
110110
synchronized (this.monitor) {
111111
Assert.state(!isStarted(), "Server already started");
112-
logger.debug("Starting live reload server on port " + this.port);
112+
if (logger.isDebugEnabled()) {
113+
logger.debug("Starting live reload server on port " + this.port);
114+
}
113115
this.serverSocket = new ServerSocket(this.port);
114116
int localPort = this.serverSocket.getLocalPort();
115117
this.listenThread = this.threadFactory.newThread(this::acceptConnections);

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ private FailureAnalysis analyze(Throwable failure, List<FailureAnalyzer> analyze
113113
}
114114
}
115115
catch (Throwable ex) {
116-
logger.debug("FailureAnalyzer " + analyzer + " failed", ex);
116+
if (logger.isDebugEnabled()) {
117+
logger.debug("FailureAnalyzer " + analyzer + " failed", ex);
118+
}
117119
}
118120
}
119121
return null;

0 commit comments

Comments
 (0)