import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
...
...
...
if (env.equals("DEV")) {
setLog4j2ConfigFile("log4j2-dev.xml");
}
private void setLog4j2ConfigFile(String log4j2ConfigFile) throws URISyntaxException {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
context.setConfigLocation(getClass().getResource(log4j2ConfigFile).toURI());
}