|
1 | 1 | /* |
2 | | - * Copyright 2002-2012 the original author or authors. |
| 2 | + * Copyright 2002-2014 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
35 | 35 | * <p>For web environments, the analogous Log4jWebConfigurer class can be found |
36 | 36 | * in the web package, reading in its configuration from context-params in |
37 | 37 | * {@code web.xml}. In a J2EE web application, log4j is usually set up |
38 | | - * via Log4jConfigListener or Log4jConfigServlet, delegating to |
39 | | - * Log4jWebConfigurer underneath. |
| 38 | + * via Log4jConfigListener, delegating to Log4jWebConfigurer underneath. |
40 | 39 | * |
41 | 40 | * @author Juergen Hoeller |
42 | 41 | * @since 13.03.2003 |
@@ -65,6 +64,10 @@ public abstract class Log4jConfigurer { |
65 | 64 | public static void initLogging(String location) throws FileNotFoundException { |
66 | 65 | String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(location); |
67 | 66 | URL url = ResourceUtils.getURL(resolvedLocation); |
| 67 | + if (ResourceUtils.URL_PROTOCOL_FILE.equals(url.getProtocol()) && !ResourceUtils.getFile(url).exists()) { |
| 68 | + throw new FileNotFoundException("Log4j config file [" + resolvedLocation + "] not found"); |
| 69 | + } |
| 70 | + |
68 | 71 | if (resolvedLocation.toLowerCase().endsWith(XML_FILE_EXTENSION)) { |
69 | 72 | DOMConfigurator.configure(url); |
70 | 73 | } |
@@ -98,6 +101,7 @@ public static void initLogging(String location, long refreshInterval) throws Fil |
98 | 101 | if (!file.exists()) { |
99 | 102 | throw new FileNotFoundException("Log4j config file [" + resolvedLocation + "] not found"); |
100 | 103 | } |
| 104 | + |
101 | 105 | if (resolvedLocation.toLowerCase().endsWith(XML_FILE_EXTENSION)) { |
102 | 106 | DOMConfigurator.configureAndWatch(file.getAbsolutePath(), refreshInterval); |
103 | 107 | } |
|
0 commit comments