It's not a secret anymore!
The moose likes Websphere and the fly likes log4j in WebSphere5.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "log4j in WebSphere5.1" Watch "log4j in WebSphere5.1" New topic

log4j in WebSphere5.1

Sam De Albin

Joined: May 10, 2004
Posts: 3
hi all

Does anybody know , how to configure log4j in websphere 5.1?? First, I developed my application for weblogic 7.1. then i ported to websphere 5.1. log4j was working fine in weblogic. But, in websphere everything is fine except log4j. Do i need to add any special entries in server specific xml files???

plz help me......

Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Moving to the IBM/Websphere Forum...
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

What error are you getting?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 364
I set up log4j in WebSphere just like anywhere else, I'd imagine. Create a servlet with init method:

public void init()
String prefix = getServletContext().getRealPath("/");
String file = getInitParameter("log4j_conf");
if (file != null)
PropertyConfigurator.configure(prefix + file);


and then in the web.xml file make sure load-on-startup is set to 1 and the log4j_conf init param value is set to the path to the file. No worries...

No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Sam De Albin

Joined: May 10, 2004
Posts: 3

i doesnt get any error!! in the file , I mentioned the file name of the logger. But, that file is not at all there when I run the pgm. Should I create a blank file before starting the Application???

I agree. Here's the link:
subject: log4j in WebSphere5.1
It's not a secret anymore!