Great thanks for the tip!
I ran into one problem though. Since I am initializing the configurator
in the static block of my code I don't have access to the non-static
method getClass().
Where do most typically initialize their log4j configurators? and how do
you check your properties file in to revision control such that they can
be accessed by people who have different project directories?
Thanks.
On Fri, 7 Sep 2001, Jon Skeet wrote:
> > I was wondering if anyone had experience initilizing their properity
> > configurators. I code that looks like:
> >
> > private static final String logFile = "c://xmlparser.properties";
> >
> > static {
> > try {
> > //read config for log4j webct logging
> > PropertyConfigurator.configureAndWatch(logFile);
> > _category = Category.getRoot();
> > _category.log(Priority.WARN, "XmlParser");
> > } catch (Exception e) {
> > e.printStackTrace();
> > }
> >
> >
> > What I am wondering is if I just tell it the name of the
> > properties file,
> > what directory does it look for it in? I need something that
> > is relative
> > to the location of the class loading it so that if multiple
> > people check
> > my soruce file out and they have different project directories on
> > different drives then it would still find the properties file.
>
> If you give a relative path, it will be relative to the working
> directory of the JVM process, which is unrelated to where the classfiles
> are. If you wish to use "class-relativity" you should load the
> properties resource yourself, probably using
> getClass().getResourceAsStream(file); (see javadoc for details) then use
> PropertyConfigurator.configure(Properties).
>
> Jon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]