We want to migrate a Java 7 web app from log4j 1.2.12 to log4j 2.12.4 and modify the app as less as possible.
The app was using SLF4J and including this dependencies:
- log4j
- slf4j-api
- slf4j-log4j12
- jcl-over-slf4j
And excluding all possible reference to commons-logging.
We replaced the previously indicated dependencies by:
- log4j-api
- log4j-core
- log4j-slf4j-impl
- slf4j-api
And we kept the commons-logging exclusion.
We are working with spring version 4.2.1, servlet 3.0 and loading the log xml configuration in an init servlet with this code:
File file = new File(pathToFile);
LoggerContext context = (LoggerContext) LogManager.getContext(false);
context.setConfigLocation(file.toURI());
Our problem is that the log configuration is only working in the web module. The rest of modules included in the project are not taking the logs configuration.
Any idea about where the problem can be and how to solve it?