Skip to content

Commit

Permalink
Lagt til logging av konfigurasjon (keys only).
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc3092 committed Oct 5, 2023
1 parent c6acd13 commit 435bb8a
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package no.nav.testnav.apps.organisasjontilgangservice;

import lombok.extern.slf4j.Slf4j;
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.stereotype.Component;

import java.util.Arrays;
import java.util.stream.StreamSupport;

@Component
@Slf4j
public class ConfiguratedEnvironmentLogger {

@EventListener
public void handleContextRefreshedEvent(ContextRefreshedEvent event) {
var env = (AbstractEnvironment) event.getApplicationContext().getEnvironment();
var propertySources = env.getPropertySources();
StreamSupport.stream(propertySources.spliterator(), false)
.filter(EnumerablePropertySource.class::isInstance)
.map(ps -> ((EnumerablePropertySource<?>) ps).getPropertyNames())
.flatMap(Arrays::stream)
.distinct()
.sorted()
.forEach(prop -> log.info("{}", prop));

}

}

0 comments on commit 435bb8a

Please sign in to comment.