Only in logging-log4j2-trunk/: .idea
Only in logging-log4j2-trunk/log4j-1.2-api: log4j-1.2-api.iml
Only in logging-log4j2-trunk/log4j-1.2-api: target
Only in logging-log4j2-trunk/log4j-api: felix-cache
Only in logging-log4j2-trunk/log4j-api: log4j-api.iml
Only in logging-log4j2-trunk/log4j-api: target
Only in logging-log4j2-trunk/log4j-bom: log4j-bom.iml
Only in logging-log4j2-trunk/log4j-bom: target
Only in logging-log4j2-trunk/log4j-core: log4j-core.iml
diff -r l2/logging-log4j2-trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java logging-log4j2-trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
335a336,346
> 	/**
> 	 *  this method is more or less internal and allows to reuse config lookup logic
> 	 *
> 	 * @param name classloader name most of the time or config name more generically
> 	 * @param configLocation config location uri (most of the time null)
> 	 * @return the config factory/config source pair for these parameters
> 	 */
> 	public ConfigEntry getConfigurationLocation(final String name, final URI configLocation) {
> 		return configFactory.getConfigurationLocation(name, configLocation);
> 	}
> 
379,439c390,393
< 
<             if (configLocation == null) {
<                 final String config = this.substitutor.replace(
<                     PropertiesUtil.getProperties().getStringProperty(CONFIGURATION_FILE_PROPERTY));
<                 if (config != null) {
<                     ConfigurationSource source = null;
<                     try {
<                         source = getInputFromUri(FileUtils.getCorrectedFilePathUri(config));
<                     } catch (final Exception ex) {
<                         // Ignore the error and try as a String.
<                         LOGGER.catching(Level.DEBUG, ex);
<                     }
<                     if (source == null) {
<                         final ClassLoader loader = this.getClass().getClassLoader();
<                         source = getInputFromString(config, loader);
<                     }
<                     if (source != null) {
<                         for (final ConfigurationFactory factory : factories) {
<                             final String[] types = factory.getSupportedTypes();
<                             if (types != null) {
<                                 for (final String type : types) {
<                                     if (type.equals("*") || config.endsWith(type)) {
<                                         final Configuration c = factory.getConfiguration(source);
<                                         if (c != null) {
<                                             return c;
<                                         }
<                                     }
<                                 }
<                             }
<                         }
<                     }
<                 }
<             } else {
<                 for (final ConfigurationFactory factory : factories) {
<                     final String[] types = factory.getSupportedTypes();
<                     if (types != null) {
<                         for (final String type : types) {
<                             if (type.equals("*") || configLocation.toString().endsWith(type)) {
<                                 final Configuration config = factory.getConfiguration(name, configLocation);
<                                 if (config != null) {
<                                     return config;
<                                 }
<                             }
<                         }
<                     }
<                 }
<             }
< 
<             Configuration config = getConfiguration(true, name);
<             if (config == null) {
<                 config = getConfiguration(true, null);
<                 if (config == null) {
<                     config = getConfiguration(false, name);
<                     if (config == null) {
<                         config = getConfiguration(false, null);
<                     }
<                 }
<             }
<             if (config != null) {
<                 return config;
<             }
---
>             final ConfigEntry config = getConfigurationLocation(name, configLocation);
> 			if (config != null) {
> 				return config.build();
> 			}
444,468c398,489
<         private Configuration getConfiguration(final boolean isTest, final String name) {
<             final boolean named = name != null && name.length() > 0;
<             final ClassLoader loader = this.getClass().getClassLoader();
<             for (final ConfigurationFactory factory : factories) {
<                 String configName;
<                 final String prefix = isTest ? TEST_PREFIX : DEFAULT_PREFIX;
<                 final String [] types = factory.getSupportedTypes();
<                 if (types == null) {
<                     continue;
<                 }
< 
<                 for (final String suffix : types) {
<                     if (suffix.equals("*")) {
<                         continue;
<                     }
<                     configName = named ? prefix + name + suffix : prefix + suffix;
< 
<                     final ConfigurationSource source = getInputFromResource(configName, loader);
<                     if (source != null) {
<                         return factory.getConfiguration(source);
<                     }
<                 }
<             }
<             return null;
<         }
---
> 		@Override
> 		public ConfigEntry getConfigurationLocation(final String name, final URI configLocation) {
> 			if (configLocation == null) {
> 				final String config = this.substitutor.replace(
> 					PropertiesUtil.getProperties().getStringProperty(CONFIGURATION_FILE_PROPERTY));
> 				if (config != null) {
> 					ConfigurationSource source = null;
> 					try {
> 						source = getInputFromUri(FileUtils.getCorrectedFilePathUri(config));
> 					} catch (final Exception ex) {
> 						// Ignore the error and try as a String.
> 						LOGGER.catching(Level.DEBUG, ex);
> 					}
> 					if (source == null) {
> 						final ClassLoader loader = this.getClass().getClassLoader();
> 						source = getInputFromString(config, loader);
> 					}
> 					if (source != null) {
> 						for (final ConfigurationFactory factory : factories) {
> 							final String[] types = factory.getSupportedTypes();
> 							if (types != null) {
> 								for (final String type : types) {
> 									if (type.equals("*") || config.endsWith(type)) {
> 										final Configuration c = factory.getConfiguration(source);
> 										if (c != null) {
> 											return new ConfigEntry(factory, source);
> 										}
> 									}
> 								}
> 							}
> 						}
> 					}
> 				}
> 			} else {
> 				for (final ConfigurationFactory factory : factories) {
> 					final String[] types = factory.getSupportedTypes();
> 					if (types != null) {
> 						for (final String type : types) {
> 							if (type.equals("*") || configLocation.toString().endsWith(type)) {
> 								if (isActive()) {
> 									final ConfigurationSource source = getInputFromUri(configLocation);
> 									if (source != null) {
> 										return new ConfigEntry(factory, source);
> 									}
> 								}
> 							}
> 						}
> 					}
> 				}
> 			}
> 
> 			ConfigEntry config = getConfigurationLocation(true, name);
> 			if (config == null) {
> 				config = getConfigurationLocation(true, null);
> 				if (config == null) {
> 					config = getConfigurationLocation(false, name);
> 					if (config == null) {
> 						config = getConfigurationLocation(false, null);
> 					}
> 				}
> 			}
> 			if (config != null) {
> 				return config;
> 			}
> 			return null;
>         }
> 
> 		private ConfigEntry getConfigurationLocation(final boolean isTest, final String name) {
> 			final boolean named = name != null && name.length() > 0;
> 			final ClassLoader loader = this.getClass().getClassLoader();
> 			for (final ConfigurationFactory factory : factories) {
> 				String configName;
> 				final String prefix = isTest ? TEST_PREFIX : DEFAULT_PREFIX;
> 				final String [] types = factory.getSupportedTypes();
> 				if (types == null) {
> 					continue;
> 				}
> 
> 				for (final String suffix : types) {
> 					if (suffix.equals("*")) {
> 						continue;
> 					}
> 					configName = named ? prefix + name + suffix : prefix + suffix;
> 
> 					final ConfigurationSource source = getInputFromResource(configName, loader);
> 					if (source != null) {
> 						return new ConfigEntry(factory, source);
> 					}
> 				}
> 			}
> 			return null;
> 		}
475c496
<         @Override
---
> 		@Override
499a521,542
> 
> 	public static class ConfigEntry {
> 		private final ConfigurationFactory factory;
> 		private final ConfigurationSource source;
> 
> 		public ConfigEntry(final ConfigurationFactory factory, final ConfigurationSource source) {
> 			this.factory = factory;
> 			this.source = source;
> 		}
> 
> 		public ConfigurationFactory getFactory() {
> 			return factory;
> 		}
> 
> 		public ConfigurationSource getSource() {
> 			return source;
> 		}
> 
> 		public Configuration build() {
> 			return factory.getConfiguration(source);
> 		}
> 	}
diff -r l2/logging-log4j2-trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java logging-log4j2-trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
25a26
> import java.net.MalformedURLException;
92,93c93,103
<         this.url = null;
<         this.data = null;
---
> 
> 		URL tmp = null;
> 		try {
> 			tmp = file.toURI().toURL();
> 		}
> 		catch (final MalformedURLException e) {
> 			// no-op
> 		}
> 
> 		this.url = tmp;
> 		this.data = null;
diff -r l2/logging-log4j2-trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java logging-log4j2-trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
20a21
> import java.net.URISyntaxException;
30a32
> import org.apache.logging.log4j.core.config.ConfigurationFactory;
184a187,188
> 
> 		URI specificConfig = configLocation;
187,216c191,232
<                 ClassLoader parent = loader.getParent();
<                 while (parent != null) {
< 
<                     ref = CONTEXT_MAP.get(parent.toString());
<                     if (ref != null) {
<                         final WeakReference<LoggerContext> r = ref.get();
<                         final LoggerContext ctx = r.get();
<                         if (ctx != null) {
<                             return ctx;
<                         }
<                     }
<                     parent = parent.getParent();
<                     /*  In Tomcat 6 the parent of the JSP classloader is the webapp classloader which would be
<                     configured by the WebAppContextListener. The WebAppClassLoader is also the ThreadContextClassLoader.
<                     In JBoss 5 the parent of the JSP ClassLoader is the WebAppClassLoader which is also the
<                     ThreadContextClassLoader. However, the parent of the WebAppClassLoader is the ClassLoader
<                     that is configured by the WebAppContextListener.
< 
<                     ClassLoader threadLoader = null;
<                     try {
<                         threadLoader = Thread.currentThread().getContextClassLoader();
<                     } catch (Exception ex) {
<                         // Ignore SecurityException
<                     }
<                     if (threadLoader != null && threadLoader == parent) {
<                         break;
<                     } else {
<                         parent = parent.getParent();
<                     } */
<                 }
---
> 				// try to locate configuration
> 				final ConfigurationFactory.ConfigEntry config = ConfigurationFactory.getInstance().getConfigurationLocation(name, null);
> 				if (config != null) {
> 					try {
> 						specificConfig = config.getSource().getURL().toURI();
> 					}
> 					catch (final URISyntaxException e) {
> 						throw new IllegalArgumentException(e);
> 					}
> 				} else {
> 
> 					ClassLoader parent = loader.getParent();
> 					while (parent != null) {
> 
> 						ref = CONTEXT_MAP.get(parent.toString());
> 						if (ref != null) {
> 							final WeakReference<LoggerContext> r = ref.get();
> 							final LoggerContext ctx = r.get();
> 							if (ctx != null) {
> 								return ctx;
> 							}
> 						}
> 						parent = parent.getParent();
> 						/*  In Tomcat 6 the parent of the JSP classloader is the webapp classloader which would be
> 						configured by the WebAppContextListener. The WebAppClassLoader is also the ThreadContextClassLoader.
> 						In JBoss 5 the parent of the JSP ClassLoader is the WebAppClassLoader which is also the
> 						ThreadContextClassLoader. However, the parent of the WebAppClassLoader is the ClassLoader
> 						that is configured by the WebAppContextListener.
> 
> 						ClassLoader threadLoader = null;
> 						try {
> 							threadLoader = Thread.currentThread().getContextClassLoader();
> 						} catch (Exception ex) {
> 							// Ignore SecurityException
> 						}
> 						if (threadLoader != null && threadLoader == parent) {
> 							break;
> 						} else {
> 							parent = parent.getParent();
> 						} */
> 					}
> 				}
218c234
<             LoggerContext ctx = new LoggerContext(name, null, configLocation);
---
>             LoggerContext ctx = new LoggerContext(name, null, specificConfig);
229,230c245,246
<             if (ctx.getConfigLocation() == null && configLocation != null) {
<                 LOGGER.debug("Setting configuration to {}", configLocation);
---
>             if (ctx.getConfigLocation() == null && specificConfig != null) {
>                 LOGGER.debug("Setting configuration to {}", specificConfig);
232,233c248,249
<             } else if (ctx.getConfigLocation() != null && configLocation != null &&
<                 !ctx.getConfigLocation().equals(configLocation)) {
---
>             } else if (ctx.getConfigLocation() != null && specificConfig != null &&
>                 !ctx.getConfigLocation().equals(specificConfig)) {
239c255
<         ctx = new LoggerContext(name, null, configLocation);
---
>         ctx = new LoggerContext(name, null, specificConfig);
diff -r l2/logging-log4j2-trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Loader.java logging-log4j2-trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Loader.java
23a24,30
> import java.util.ArrayList;
> import java.util.Collection;
> import java.util.Collections;
> import java.util.Enumeration;
> import java.util.HashSet;
> import java.util.List;
> import java.util.Set;
117,119c124,137
<                 final URL url = classLoader.getResource(resource);
<                 if (url != null) {
<                     return url;
---
>                 final Collection<URL> url = new HashSet<URL>(Collections.list(classLoader.getResources(resource)));
>                 if (!url.isEmpty()) {
> 					if (url.size() > 1) { // remove parent ones to keep only the most specific one
> 						final ClassLoader parent = classLoader.getParent();
> 						if (parent != null) {
> 							final Collection<URL> child = new HashSet<URL>(url);
> 							child.removeAll(Collections.list(parent.getResources(resource)));
> 							if (!child.isEmpty()) {
> 								return child.iterator().next();
> 							}
> 						}
> 					}
> 					// only child config, we are safe to use one of them
>                     return url.iterator().next();
Only in logging-log4j2-trunk/log4j-core/src/test/java/org/apache/logging/log4j/test: ClassLoaderHierarchyContextPriorityRulesTest.java
Only in logging-log4j2-trunk/log4j-core/src/test/resources: classloader
Only in logging-log4j2-trunk/log4j-core: target
Only in logging-log4j2-trunk/log4j-flume-ng: log4j-flume-ng.iml
Only in logging-log4j2-trunk/log4j-flume-ng: target
Only in logging-log4j2-trunk/: log4j.iml
Only in logging-log4j2-trunk/log4j-jcl: log4j-jcl.iml
Only in logging-log4j2-trunk/log4j-jcl: target
Only in logging-log4j2-trunk/log4j-jmx-gui: log4j-jmx-gui.iml
Only in logging-log4j2-trunk/log4j-jmx-gui: target
Only in logging-log4j2-trunk/log4j-nosql: log4j-nosql.iml
Only in logging-log4j2-trunk/log4j-nosql: target
Only in logging-log4j2-trunk/log4j-perf: log4j-perf.iml
Only in logging-log4j2-trunk/log4j-perf: target
Only in logging-log4j2-trunk/log4j-samples/flume-common: log4j-samples-flume-common.iml
Only in logging-log4j2-trunk/log4j-samples/flume-common: target
Only in logging-log4j2-trunk/log4j-samples/flume-embedded: log4j-samples-flume-embedded.iml
Only in logging-log4j2-trunk/log4j-samples/flume-embedded: target
Only in logging-log4j2-trunk/log4j-samples/flume-remote: log4j-samples-flume-remote.iml
Only in logging-log4j2-trunk/log4j-samples/flume-remote: target
Only in logging-log4j2-trunk/log4j-samples: log4j-samples.iml
Only in logging-log4j2-trunk/log4j-samples: target
Only in logging-log4j2-trunk/log4j-slf4j-impl: log4j-slf4j-impl.iml
Only in logging-log4j2-trunk/log4j-slf4j-impl: target
Only in logging-log4j2-trunk/log4j-taglib: log4j-taglib.iml
Only in logging-log4j2-trunk/log4j-taglib: target
Only in logging-log4j2-trunk/log4j-to-slf4j: log4j-to-slf4j.iml
Only in logging-log4j2-trunk/log4j-to-slf4j: target
Only in logging-log4j2-trunk/log4j-web: log4j-web.iml
Only in logging-log4j2-trunk/log4j-web: target
Only in logging-log4j2-trunk/: target
