Java – controls the classpath in the servlet

My servlet application contains many libraries Jars, some of which contain embedded log4j XML or log4j Properties file I want to make sure log4j finds my log4j first xml! I have tried to search the servlet for some specifications of the priority of various classpath elements (for example, is WEB-INF / classes always before WEB-INF / lib?), Or some way to configure or adjust the servlet classloader so that a given resource directory appears early in the classpath So far, I have drawn a blank About making sure that the servlet The war file loads the correct log4j through the class loader Any suggestions for XML?

Solution

As far as I know, the selection of resources in the classpath is non deterministic (from the perspective of application developers) Even if the same file is loaded consistently, the behavior may change:

The simplest solution is to delete the embedded log4j configuration file from the library jar Embedding log4j configuration is hardly a good idea because it will cause the problems you see here

Are they third-party jars or jars you developed?

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>