Search code examples
javalog4jweblogicweblogic-10.x

Log4j logging problem with 2 ears in Weblogic


I'm deploying 2 ears in Weblogic 10, A and B. In both of them I have a "log4j.properties" file. At the startup, when the first ear is loading, the logs are to the right file "A.log", but when the second ear is loading, all logs are going to the "B.log" file, even logs related to the first ear. I missed something... any idea ?

Thanks

Edit/Solution : Classloader issue. Add to the weblogic-application.xml :

<wls:prefer-application-packages> <wls:package-name>org.apache.log4j.*</wls:package-name> </wls:prefer-application-packages>

Thks to everyone :)


Solution

  • It would be my guess that the log4j library that is used by the Weblogic server is used in both your web applications.

    If this is the case, both web apps would share a root classloader serving the global libraries loade by Weblogic.

    If your web apps each provide a copy of log4j, and if you can choose to load the application classes before the server classes (I don't know Weblogic but for WebSphere the setting is 'classloader mode: parent first / parent last') that might solve your problem.