我的WAR应用程序结构如下:
MyApp |_ WEB-INF/ |_ log4j.xml -> Print to File |_ libs/ |_ abc.jar/ |_log4j.xml -> Print to STDOUT
因此,在我的应用程序加载时,它将在WEB-INF下选择log4j.xml并开始登录文件。 但是,从abc.jar请求的任何类都将开始在该abc.jar中加载类以及资源,从而替换到STDOUT的日志记录。而且,文件记录突然弯曲了:(
我们可以覆盖/忽略依赖项jar文件中可用的底层log4j.xml吗?
Web服务器日志:
loadClass(java.io.PrintStream, false) Returning class from cache loadClass(java.lang.StringBuilder, false) Returning class from cache loadClass(java.lang.StringBuffer, false) Returning class from cache loadClass(xxx.xxxx.ServiceHandle, false) Searching local repositories findClass(xxx.xxxx.ServiceHandle) Loading class from local repository loadClass(xxx.xxxx.ServiceNotFoundException, false) Searching local repositories findClass(xxx.xxxx.ServiceNotFoundException) Loading class from local repository loadClass(xxx.xxxx.RawDataCallback, false) Searching local repositories findClass(xxx.xxxx.RawDataCallback) Loading class from local repository loadClass(xxx.xxxx.Logger, false) Searching local repositories findClass(xxx.xxxx.Logger) Loading class from local repository loadClass(org.apache.log4j.spi.LoggerFactory, false) Delegating to parent classloader1 java.net.URLClassLoader@2a098129 Loading class from parent loadClass(org.apache.log4j.or.ObjectRenderer, false) Delegating to parent classloader1 java.net.URLClassLoader@2a098129 Loading class from parent loadClass(xxx.xxxx.Logger$DataRecordRenderer, false) Searching local repositories findClass(xxx.xxxx.Logger$DataRecordRenderer) Loading class from local repository loadClass(org.apache.log4j.LogManager, false) Delegating to parent classloader1 java.net.URLClassLoader@2a098129 Loading class from parent getResource(log4j.xml) findResource(log4j.xml) --> Returning 'jar:file:serverPath/WEB-INF/lib/xxx.xxxx-1.0.0.jar!/log4j.xml' --> Returning 'jar:file:serverPath/WEB-INF/lib/xxx.xxxx-1.0.0.jar!/log4j.xml' loadClass(org.apache.log4j.xml.DOMConfigurator, false) Delegating to parent classloader1 java.net.URLClassLoader@2a098129 Loading class from parent findResources(META-INF/services/javax.xml.parsers.DocumentBuilderFactory) loadClass(com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl, false) ......... No more logging ...........