mirror of
https://github.com/rasilon/ujetl.git
synced 2026-04-11 10:29:29 +00:00
Change how log4j finds its config.
log4j is reacting less well to reconfigurations, so this moves the config file location to earlier in the process, so that no class sees an unconfigured instance.
This commit is contained in:
parent
441b2f4191
commit
866d02fb52
5 changed files with 2 additions and 13 deletions
|
|
@ -34,10 +34,6 @@ public class CopyingApp {
|
|||
public static void main(String[] args) {
|
||||
CopyingAppCommandParser cli = new CopyingAppCommandParser(args);
|
||||
LoggerContext context = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false);
|
||||
String log4jConfigLocation = cli.getLog4jConfigFile();
|
||||
File file = new File(log4jConfigLocation);
|
||||
context.setConfigLocation(file.toURI());
|
||||
System.out.println("Config set from "+file.toURI());
|
||||
|
||||
CopyingApp app = new CopyingApp(cli);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -23,8 +23,4 @@ public class CopyingAppCommandParser {
|
|||
return configFile;
|
||||
}
|
||||
|
||||
public String getLog4jConfigFile() {
|
||||
return log4jConfigFile;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,15 +13,12 @@ public class TestParser {
|
|||
public void test001Parset() {
|
||||
try {
|
||||
String[] args = {
|
||||
"--log4j",
|
||||
"log4j_test_banana.xml",
|
||||
"--config",
|
||||
"config_test_banana.xml"
|
||||
};
|
||||
CopyingAppCommandParser p = new CopyingAppCommandParser(args);
|
||||
|
||||
assertEquals(p.getConfigFile(),"config_test_banana.xml");
|
||||
assertEquals(p.getLog4jConfigFile(),"log4j_test_banana.xml");
|
||||
|
||||
} catch(Exception e) {
|
||||
fail(e.toString());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue