LoggerFactory question help

question 1: Can somebody tell me when loggerFactoryClassLoader will be null? static Set<URL> findPossibleStaticLoggerBinderPathSet() { // use Set instead of list in order to deal with bug #138 // LinkedHashSet appropriate here because it preserves insertion order // during iteration Set<URL> staticLoggerBinderPathSet = new LinkedHashSet<URL>(); try { ClassLoader loggerFactoryClassLoader = LoggerFactory.class.getClassLoader(); Enumeration<URL> paths; if (loggerFactoryClassLoader == null) { paths = ClassLoader.getSystemResources(STATIC_LOGGER_BINDER_PATH); } else { paths = loggerFactoryClassLoader.getResources(STATIC_LOGGER_BINDER_PATH); } while (paths.hasMoreElements()) { URL path = paths.nextElement(); staticLoggerBinderPathSet.add(path); } } catch (IOException ioe) { Util.report("Error getting resources from path", ioe); } return staticLoggerBinderPathSet; } question 2: ClassLoader.getSystemResources(STATIC_LOGGER_BINDER_PATH) and loggerFactoryClassLoader.getResources(STATIC_LOGGER_BINDER_PATH) are the same meaning in jdk. public static Enumeration<URL> getSystemResources(String name) throws IOException { ClassLoader system = getSystemClassLoader(); if (system == null) { return getBootstrapResources(name); } return system.getResources(name); } public Enumeration<URL> getResources(String name) throws IOException { Enumeration[] tmp = new Enumeration[2]; if (parent != null) { tmp[0] = parent.getResources(name); } else { tmp[0] = getBootstrapResources(name); } tmp[1] = findResources(name); return new CompoundEnumeration<>(tmp); } thank for help.

1. According to the docs for getClassLoader(), the bootstrap ClassLoader can be represented as null, which will cause loggerFactoryClassLoader to be null. 2. getSystemResources can return different results, depending on whether the system or bootstrap ClassLoader is used. getResources is tied to whatever ClassLoader instance is there, which isn't necessarily the system or bootstrap ClassLoader.

Thanks very much."the bootstrap ClassLoader can be represented as null" help me very much. Another question.When LoggerFactory.class.getClassLoader() will be bootstrapclassloader. I think BootStrapClassloader is always load jdk's class which path like 'jre/lib/* jre/classs/*'。org.slf4j.LoggerFacoty would not be loaded by Bootstrapclassloader? 2016-12-29 13:31 GMT+08:00 Nathan Green <ngreen@inco5.com>:
1. According to the docs for getClassLoader(), the bootstrap ClassLoader can be represented as null, which will cause loggerFactoryClassLoader to be null. 2. getSystemResources can return different results, depending on whether the system or bootstrap ClassLoader is used. getResources is tied to whatever ClassLoader instance is there, which isn't necessarily the system or bootstrap ClassLoader.
_______________________________________________ slf4j-dev mailing list slf4j-dev@qos.ch http://mailman.qos.ch/mailman/listinfo/slf4j-dev
participants (2)
-
Nathan Green
-
雪松