From 0769b33e2ecd85edcd23076504d473a03a1852d5 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 1 Nov 2021 09:48:10 +0200 Subject: [PATCH] Log the reason that led Devtools to restart the app See gh-28495 --- .../devtools/classpath/ClassPathFileChangeListener.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListener.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListener.java index 4339bcbffe8..4d6c4608e17 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListener.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListener.java @@ -18,6 +18,9 @@ package org.springframework.boot.devtools.classpath; import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.springframework.boot.devtools.filewatch.ChangedFile; import org.springframework.boot.devtools.filewatch.ChangedFiles; import org.springframework.boot.devtools.filewatch.FileChangeListener; @@ -35,6 +38,8 @@ import org.springframework.util.Assert; */ class ClassPathFileChangeListener implements FileChangeListener { + private static final Log logger = LogFactory.getLog(ClassPathFileChangeListener.class); + private final ApplicationEventPublisher eventPublisher; private final ClassPathRestartStrategy restartStrategy; @@ -60,6 +65,9 @@ class ClassPathFileChangeListener implements FileChangeListener { @Override public void onChange(Set changeSet) { boolean restart = isRestartRequired(changeSet); + if (restart && logger.isDebugEnabled()) { + logger.debug("Restarting dev tools due to changes in the following files: " + changeSet); + } publishEvent(new ClassPathChangedEvent(this, changeSet, restart)); }