LoginSignup
0
0

More than 1 year has passed since last update.

Java - How to Set Difference Configuration Files for Log4j2

Last updated at Posted at 2021-10-15
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());
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0