Skip to content

Commit

Permalink
Merge pull request #1471 from ivangsa/features/logbackConfigMain
Browse files Browse the repository at this point in the history
Check for logback-test.xml file in classpath in Main.class
  • Loading branch information
ptrthomas authored Feb 4, 2021
2 parents 343487a + deaa44c commit 2617187
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion karate-core/src/main/java/com/intuit/karate/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.intuit.karate.http.ServerConfig;
import com.intuit.karate.http.SslContextFactory;
import com.intuit.karate.job.JobExecutor;
import com.intuit.karate.resource.ResourceUtils;
import com.intuit.karate.shell.Command;
import java.io.File;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -272,7 +273,15 @@ public static void main(String[] args) {
// ensure we init logback before anything else
String logbackConfig = System.getProperty(LOGBACK_CONFIG);
if (StringUtils.isBlank(logbackConfig)) {
System.setProperty(LOGBACK_CONFIG, "logback-fatjar.xml");
File logbackXml = ResourceUtils.classPathToFile("logback.xml");
File logbackTest = ResourceUtils.classPathToFile("logback-test.xml");
if (logbackTest != null) {
System.setProperty(LOGBACK_CONFIG, "logback-test.xml");
} else if (logbackXml != null) {
System.setProperty(LOGBACK_CONFIG, "logback.xml");
} else {
System.setProperty(LOGBACK_CONFIG, "logback-fatjar.xml");
}
}
}
resetLoggerConfig();
Expand Down

0 comments on commit 2617187

Please sign in to comment.