We have a spring boot application using log4j2.
We want to use different log levels for different profiles. After lot of struggles, I found out that this is not possible with log4j2 but it is possible with logback. I don't want to use logback though.
Reason this is not possible with log4j2 is - spring boot initializes log4j2 well before it loads application properties.
So, I have initialized log4j2 with all the default values in log4j2.xml and after the application has started up, I'm getting the logger context and changing the log levels as per the profile specific log levels programmatically.
Though this is working, just wanted to understand if there is any better way.