com.netgrif.application.engine.configuration.PropertyLogger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of application-engine Show documentation
Show all versions of application-engine Show documentation
System provides workflow management functions including user, role and data management.
package com.netgrif.application.engine.configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.env.AbstractEnvironment;
import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.stream.StreamSupport;
@Component
public class PropertyLogger {
private static final Logger log = LoggerFactory.getLogger(PropertyLogger.class);
@EventListener
public void logProperties(ContextRefreshedEvent event) {
final Environment env = event.getApplicationContext().getEnvironment();
log.info("====== Environment and configuration ======");
log.info("Active profiles: {}", Arrays.toString(env.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) env).getPropertySources();
StreamSupport.stream(sources.spliterator(), false)
.filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames())
.flatMap(Arrays::stream)
.distinct()
.filter(prop -> !(prop.contains("credentials") || prop.contains("password")))
.forEach(prop -> log.info("{}: {}", prop, env.getProperty(prop)));
log.info("===========================================");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy