2

I want a separate configuration for each of my war files and I want them to read the log4j.properties files from external locations. But when I used the PropertyConfigurator.configure , somehow Weblogic tries to append the configuration to all applications over the same JVM.

I know that applications should see their own log4j.jar's from their lib folders but weblogic also has a log4j jar under its lib folder.

How can I fix this?

Thanks

oers
  • 18,436
  • 13
  • 66
  • 75
Neron
  • 1,500
  • 7
  • 30
  • 52
  • I found the problem. My log4j.properties file was under one of my classpath folder and log4j ,by default, sees that file for everything. Just do not put your log4j file under a classpath folder. And to make the separation between applications for log4j, do not use log4j.jar in your startup classpath. if u had a problem about this, use prefer-webinf-classes attribute for weblogic to ensure that your application will use the jar under your lib. – Neron Feb 09 '12 at 12:56
  • Please post this as an answer (and accept it) as soon as it is possible for you :) – oers Feb 09 '12 at 14:24
  • Ehe:) Hope so. I need some rep – Neron Feb 09 '12 at 14:30
  • @Neron now you have the reputation, go ahead and add an answer :) – Viccari Feb 16 '12 at 23:11

1 Answers1

2

I found the problem. My log4j.properties file was under one of my classpath folder and log4j ,by default, sees that file for everything. Just do not put your log4j file under a classpath folder. And to make the separation between applications for log4j, do not use log4j.jar in your startup classpath. if u had a problem about this, use prefer-webinf-classes attribute for weblogic to ensure that your application will use the jar under your lib.

Neron
  • 1,500
  • 7
  • 30
  • 52
  • I am using tomcat and have multiple wars deployed, how do I configure my log properties in that case, so that logs of individual war files go to their respective log files. – ViS May 25 '17 at 13:23
  • @ViS here: https://stackoverflow.com/questions/2288876/how-to-configure-log4j-with-a-properties-file – Neron Jun 01 '17 at 06:05