The below seems to work, although I'm not sure if the instance always has type ConfigurableEnvironment
@Component
public class MyListener implements ApplicationListener<ContextRefreshedEvent>{
@Autowired
private Environment env;
private static final Logger log = LoggerFactory.getLogger(MyListener.class);
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if(env instanceof ConfigurableEnvironment){
MutablePropertySources propertySources = ((ConfigurableEnvironment)env).getPropertySources();
for(PropertySource ps : propertySources){
log.info(ps.getName());
}
}
}
}
Edit: don't need all of this. As Selim already answered, turning on the right magazines does the trick
log4j.logger.org.springframework.core.env.MutablePropertySources=DEBUG
source
share