My servlet application includes a number of library .jars, some of which contain embedded log4j.xml or log4j.properties files. I\'d like to ensure that log4j finds my log4j.
Ditto Tomcat 8.0.
See documentation: Class Loader HOW-TO.
The answer is simple, taken from the Tomcat documentation page, Class Loader HOW-TO. In particular notice the use of the /WEB-INF/ directory/folder.
Therefore, from the perspective of a web application, class or resource loading looks in the following repositories, in this order:
- Bootstrap classes of your JVM
/WEB-INF/classesof your web application/WEB-INF/lib/*.jarof your web application- System class loader classes (described above)
- Common class loader classes (described above)
If the web application class loader is configured with
then the order becomes:
- Bootstrap classes of your JVM
- System class loader classes (described above)
- Common class loader classes (described above)
/WEB-INF/classesof your web application/WEB-INF/lib/*.jarof your web application
Excerpted from Tomcat 6 page, Class Loader HOW-TO.
Therefore, from the perspective of a web application, class or resource loading looks in the following repositories, in this order:
- Bootstrap classes of your JVM
- System class loader classes (described above)
/WEB-INF/classesof your web application/WEB-INF/lib/*.jarof your web application$CATALINA_HOME/lib$CATALINA_HOME/lib/*.jar