tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Layman <>
Subject RE: Answer three simple questions and I will be thrilled.
Date Wed, 21 Feb 2001 16:29:10 GMT

See replies intermixed.

-----Original Message-----
From: Alex Colic []
Sent: Wednesday, February 21, 2001 11:52 AM
Subject: Answer three simple questions and I will be thrilled.


I am trying to get a handle on Log4J and I have three problems/questions I
am trying to get

First I am trying to use log4j with a web app that is distributed in a
standard war file. I want
to be able to distribute this file, along with the logging class and not
worry about configuring

In my code I have PropertyConfigurator.configure("path to");

As a result I have to set this path every time I distribute the war file.
Is it possible to set this up so that the class file looks to where it has
been installed and
looks for there. This way I don't have to worry about
setting to

You can use ServletContext.getResource/getResourceAsStream or the same
methods on the ClassLoader.  This might give you a URL similar to
jar://path_to_WAR:entry_in_war_file, which might not be writable.

Second, I have a rolling file set in via:

How can I do the same as in step one, have this file default to where the
war file was installed?

There is one problem with this - what happens if its installed into a web
server that doesn't expand WAR files?  The spec does not require the files
be expanded, and you can't necessary add files to existing WARs though the
normal writing methods.  If you want to find the directory that the WAR is
in then you could use ServletContext.getRealPath("some file we know exists")
and then chop off the end.

Third, I have the following code in each of my class files:
Category cat=Category.getinstance(myclass.class.getName());
How can I have the above through reflection find its own class name and
therefore I would have a
default statement? Something like

This one I'm not sure about.  From within an instance you can call
getClass() that returns a handle to the java.lang.Class object of this
class, but I don't think this works from a static context.  If your have
some form of a pre-processor you can run on your code you might be able to
do a text replacement on the code, but I don't think this is possible in
straight java.

Thanks for any help.



Alex Colic, HBA, B. Ed
PopWare Inc. "Driving down the cost of conversions"
Tel: 1-905-777-8171 ext. 104
Fax: 1-905-777-0132

Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices!

To unsubscribe, e-mail:
For additional commands, email:

View raw message