| 800 | } |
| 801 | |
| 802 | @VisibleForTesting |
| 803 | static Properties log4jConfAsProperties(String log4jconf) { |
| 804 | final Properties properties = new Properties(); |
| 805 | if (!Strings.isNullOrEmpty(log4jconf)) { |
| 806 | Reader propertyReader = null; |
| 807 | try { |
| 808 | final File file = new File(log4jconf); |
| 809 | if (file.exists()) { |
| 810 | propertyReader = new FileReader(file); |
| 811 | properties.load(propertyReader); |
| 812 | log.info("Loaded log4j properties from file: " + file); |
| 813 | } else { |
| 814 | final URL resource = Main.class.getClassLoader().getResource(log4jconf); |
| 815 | if (resource != null) { |
| 816 | propertyReader = new InputStreamReader(resource.openStream(), Charset.forName("UTF-8")); |
| 817 | properties.load(propertyReader); |
| 818 | log.info("Loaded log4j properties from resource: " + resource); |
| 819 | } else { |
| 820 | log.warn("No file or resource found by the name: " + log4jconf); |
| 821 | } |
| 822 | } |
| 823 | } catch (IOException e) { |
| 824 | log.warn("Cannot open log4j properties file " + log4jconf + ", using default"); |
| 825 | } finally { |
| 826 | Closeables.closeQuietly(propertyReader); |
| 827 | } |
| 828 | } |
| 829 | return properties; |
| 830 | } |
| 831 | |
| 832 | private static List<String> fetchRemoteParamFiles(List<String> paramFiles, Properties properties) |
| 833 | throws IOException { |