import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.event.ApplicationPreparedEvent; import org.springframework.context.ApplicationListener; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.EnumerablePropertySource; import org.springframework.core.env.PropertySource; import java.util.Arrays; import java.util.LinkedList; import java.util.List; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication springApplication = new SpringApplication(Application.class); // For development purposes only. DO NOT log system properties in live envs. springApplication.addListeners(new PropertiesLogger()); springApplication.run(args); } @Slf4j private static class PropertiesLogger implements ApplicationListener { private ConfigurableEnvironment environment; private boolean isFirstRun = true; @Override public void onApplicationEvent(ApplicationPreparedEvent event) { if (isFirstRun) { environment = event.getApplicationContext().getEnvironment(); printProperties(); } isFirstRun = false; } public void printProperties() { for (EnumerablePropertySource propertySource : findPropertiesPropertySources()) { log.info("******* " + propertySource.getName() + " *******"); String[] propertyNames = propertySource.getPropertyNames(); Arrays.sort(propertyNames); for (String propertyName : propertyNames) { String resolvedProperty = environment.getProperty(propertyName); String sourceProperty = propertySource.getProperty(propertyName).toString(); if(resolvedProperty.equals(sourceProperty)) { log.info("{}={}", propertyName, resolvedProperty); }else { log.info("{}={} OVERRIDDEN to {}", propertyName, sourceProperty, resolvedProperty); } } } } private List findPropertiesPropertySources() { List propertiesPropertySources = new LinkedList<>(); for (PropertySource propertySource : environment.getPropertySources()) { if (propertySource instanceof EnumerablePropertySource) { propertiesPropertySources.add((EnumerablePropertySource) propertySource); } } return propertiesPropertySources; } } }