This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Websphere and the fly likes Log4j problem in Websphere Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Log4j problem in Websphere" Watch "Log4j problem in Websphere" New topic
Author

Log4j problem in Websphere

Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 178
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
Bartender

Joined: Oct 14, 2005
Posts: 18985
    
    8

You didn't say where you put the log4j.jar file, and that is probably what is wrong.
Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 178
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

Joined: Nov 20, 2008
Posts: 254
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?


“Everything should be as simple as it is, but not simpler.” Albert Einstein
Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 178
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

Joined: Nov 20, 2008
Posts: 254
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

Joined: Jan 07, 2007
Posts: 178
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

Joined: Nov 29, 2008
Posts: 21
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Log4j problem in Websphere