Hi Guys,
Its too long but I request you to go through this and help me..
I work in a maintenance proect and recently we got this problem...
We have 10 different applications deployed to a single weblogic server(10.x) and we need logs of each application to be directed to different files. So we used to have log4j.properties file defined and bundled along with each ear file. It worked for several years. But now all of a sudden, server is unable to load log4j.properties files of all applications
(Surprisingly it is happening only in Integration environment. In other environments, UAT and PROD, the same ear files are working fine. I dont know what's causing this, however weblogic versions in integration and other environments differ by a minor release... I mean all are 10.x bu they differ in sub-versions. I dont remember the exact version numbers.) Every time we deploy it takes only one file... we actually started the server in log4j debug mode and found that its only loading one log4j.properties file each time... The team who is responsible for the server related issues advised that
you should centralize the log4j configuration and place it in some kind of shared folder where the server can find it.
We didn't have much of a choice and started working on this... I have tried a couple of options with little or no luck...
1) I defined loggers for each application and the corresponding RollingFileAppenders in the properties file and placed it in the shared path. But the problem is I have to change the way of getting Logger instance in each and every
Java file. Earlier we used to get the Logger instance by sending the callers Class instance as an argument. Now I have to change this and send the logger name as an argument.
It worked, but I am not willing to go this way as it is a tedious process to change this in all 10 applications.
2) I thought of defining properties programatically at application level. I did the below in ServletContextListener of each application...
I hoped that this would work, but to my surprise, configuration done in one context listener is being overridden by the configuration done in other listener of a different application. And finally all the logs are ending up in a single file. I believe that there will be a different classloader for each context and I hoped that configuration of one context wouldn't be affected by that of the other.
I have lots of questions and need answers. Can anyone answer my queries and if there is a better way to achieve my requirement, please let me know.
Thanks,
Ashok