yaml - How to log the active configuration in a Spring Boot application? -
i use yaml config spring boot, find quite readable , useful have single file showing properties active in different profiles. unfortunately, i'm finding setting properties in application.yml
can rather fragile.
things using tab instead of spaces cause properties not exist (without warnings far can see), , find active profiles not being set, due unknown issue yaml.
so wondering whether there hooks enable me hold of active profiles , properties, log them.
similarly, there way cause start-up fail if application.yml
contains errors? either or means me validate yaml myself, kill start-up process.
i had same problem, , wish there debug flag tell profile processing system spit out useful logging. 1 possible way of doing register event listener application context, , print out profiles environment. haven't tried doing way myself, mileage may vary. think maybe what's outlined here:
how add hook application context initialization event?
then you'd in listener:
system.out.println("active profiles: " + arrays.tostring(ctxt.getenvironment().getactiveprofiles()));
might worth try. way declare environment injected in code need print profiles. i.e.:
@component public class someclass { @autowired private environment env; ... private void dumpprofiles() { // print whatever needed env here } }
Comments
Post a Comment