This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Configuring log4j for different applications deployed on a single weblogic server

Posts: 15
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 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 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 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.

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ashok,

I am facing same issue. Please share your suggestion if you found solution for below log4j issues.

Posts: 9588
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's really strange. I have multiple applications deployed on WLS 12 (originally WLS 10) and they write to different log files. I wonder if Weblogic has Log4j in the server classpath and that is why it isn't reading the application configuration files. If this is the case, adding the prefer-web-inf-classes, prefer-application-packages and prefer-application-resources elements to weblogic.xml should override this behavior. Do you have the Log4j.jar bundled with your app?
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!