From fff6d2f9ec497ebe81f00cc95aff7b6d744e0641 Mon Sep 17 00:00:00 2001 From: Ox To A Cart Date: Tue, 4 Feb 2014 09:00:33 -0600 Subject: [PATCH] #133 Removed log4j.xml from jar --- .../java/org/littleshoot/proxy/Launcher.java | 5 ++- .../littleshoot/proxy/impl/ProxyUtils.java | 6 ++- src/main/resources/log4j.xml | 45 ------------------- 3 files changed, 8 insertions(+), 48 deletions(-) delete mode 100644 src/main/resources/log4j.xml diff --git a/src/main/java/org/littleshoot/proxy/Launcher.java b/src/main/java/org/littleshoot/proxy/Launcher.java index 02f4002f5..825f77007 100755 --- a/src/main/java/org/littleshoot/proxy/Launcher.java +++ b/src/main/java/org/littleshoot/proxy/Launcher.java @@ -12,6 +12,7 @@ import org.apache.commons.cli.UnrecognizedOptionException; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.PropertyConfigurator; +import org.apache.log4j.xml.DOMConfigurator; import org.littleshoot.proxy.extras.SelfSignedMitmManager; import org.littleshoot.proxy.impl.DefaultHttpProxyServer; import org.littleshoot.proxy.impl.ProxyUtils; @@ -125,9 +126,9 @@ private static void printHelp(final Options options, private static void pollLog4JConfigurationFileIfAvailable() { File log4jConfigurationFile = new File( - "src/main/resources/log4j.properties"); + "src/test/resources/log4j.xml"); if (log4jConfigurationFile.exists()) { - PropertyConfigurator.configureAndWatch( + DOMConfigurator.configureAndWatch( log4jConfigurationFile.getAbsolutePath(), 15); } } diff --git a/src/main/java/org/littleshoot/proxy/impl/ProxyUtils.java b/src/main/java/org/littleshoot/proxy/impl/ProxyUtils.java index 82a9fd4bf..e8e3d5a37 100644 --- a/src/main/java/org/littleshoot/proxy/impl/ProxyUtils.java +++ b/src/main/java/org/littleshoot/proxy/impl/ProxyUtils.java @@ -302,12 +302,16 @@ public static boolean extractBooleanDefaultTrue(final Properties props, } public static int extractInt(final Properties props, final String key) { + return extractInt(props, key, -1); + } + + public static int extractInt(final Properties props, final String key, int defaultValue) { final String readThrottleString = props.getProperty(key); if (StringUtils.isNotBlank(readThrottleString) && NumberUtils.isNumber(readThrottleString)) { return Integer.parseInt(readThrottleString); } - return -1; + return defaultValue; } public static boolean isCONNECT(HttpObject httpObject) { diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml deleted file mode 100644 index 245165128..000000000 --- a/src/main/resources/log4j.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -