Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Log4j problem in Websphere

 
Vijay Chandran
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,

I have 3 EAR applications deployed in Websphere Application Server 6.1. All EAR files contian a WAR file inside it. I have specified the log4j.properties file inside the WEB-INF/classes folder in all the 3 applications. The log files have different path for all the 3 applications. For Example:

Following is the log file path mentioned in the log4j.properties file for all the 3 EAR applications:

EAR application 1: log4j.appender.log.File=C:/EAROne/log/EAROne.log
EAR application 2: log4j.appender.log.File=C:/EARTwo/log/EARTwo.log
EAR application 3: log4j.appender.log.File=C:/EARThree/log/EARThree.log

The problem is, if i execute any EAR application. all the logs are written in the same log file. Suppose if i execute application EAROne, the logs generated from the application are written in the EAROne.log. Similarly, if i execute applications EARTwo and EARThree, the logs generated from those applications are also written in the same EAROne.log file.

How to make the applications write their respective logs in their own log files according to the log file paths mentioned in their respective log4j.properties file?

Thanks in Advance,
Vijay
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't say where you put the log4j.jar file, and that is probably what is wrong.
 
Vijay Chandran
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

I've put the log4j.jar file in the WEB-INF/lib folder.

Thank you very much for the reply.

How the problem can be resolved?

Kindly help

Regards,
Vijay
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems they are sharing the same log4j library.

(1) What is the settings for class loader of each EAR and of the virtual server on which you deployed these EARs?
(2) Do you have any other log4j.jar in the server classpath?
 
Vijay Chandran
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply.

(1)How to check the class loader settings in websphere application server 6.1?

(2) I have put all the log4j.jar in the respectiver EAR application's WEB-INF/lib folder. So each EAR file has its own log4j.jar file.
There is a log4j.jar in the C:\Program Files\IBM\WebSphere\AppServer\lib folder. The version of log4j.jar is 1.2.8

Kindly help.

Regards,
Vijay
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijay Chandran wrote:
(1)How to check the class loader settings in websphere application server 6.1?

Open Administrative Console -> servers -> application servers -> server1 (or the name of your server)
In the general properties section, make sure "Classloader policy" is multiple and "Class loading mode" is parent last.

Vijay Chandran wrote:
(2) I have put all the log4j.jar in the respectiver EAR application's WEB-INF/lib folder. So each EAR file has its own log4j.jar file.
There is a log4j.jar in the C:\Program Files\IBM\WebSphere\AppServer\lib folder. The version of log4j.jar is 1.2.8

Yes, it is the problem. The above settings can't fix it, you may want to try to remove this log4j.jar as well (be careful though since the server may already be configured to use log4j).

Hope it help.
 
Vijay Chandran
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friend,

Sorry for the late reply. I was not feeling well for the past 4 days.

The suggestion you provided worked and now logging is happening perfectly.

Thank you very much,
Vijay
 
siva kumarl
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vijay Chandran,

I am also facing the same problem for wiriting log in Websphere 7.0 server, and tried all the above metioned settings but it is not working. Could you please let me know the changes you have made.

Thanks in Advance,
Siva Kumar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic