java.util.logging, where to put logging.properties?

J

janne

I am doing some coding using java.util.logging, and can't seem to
figure out where to put logging.properties so that it could be found.
Actually I can get the properties working if I include the whole path
to the file in the -D initialization parameter, as in:

C:\Java\eclipse\workspace\projX\bin>java
-Djava.util.logging.config.file=C:\Java\eclipse\workspace\projX\bin\logging.properties
com.jannem.test.BasicTest

also, if I use a relative path to logging.properties from my current
directory, that works as well. But that's all a bit clumsy, I was
expecting that I could put logging.properties in my CLASSPATH
somewhere, and command

C:\Java\eclipse\workspace\projX\bin>java
-Djava.util.logging.config.file=logging.properties
com.jannem.test.BasicTest

would be able to find it. But it does not seem to be. I do not want to
modify the JRE-wide settings, I want to include a specific
configuration file for this application.

One attempt I tried was to put the whole thing to JAR, but I had no
luck with that either:

C:\Java\eclipse\workspace\projX>unzip -l test.jar
Archive: test.jar
Length Date Time Name
-------- ---- ---- ----
0 10-09-04 12:32 META-INF/
106 10-09-04 12:32 META-INF/MANIFEST.MF
0 10-09-04 11:49 com/
0 10-09-04 11:49 com/jannem/
0 10-09-04 11:49 com/jannem/test/
1425 10-09-04 12:06 com/jannem/test/BasicTest.class
2344 10-09-04 12:23 logging.properties
-------- -------
3875 7 files

C:\Java\eclipse\workspace\projX>java -cp test.jar
-Djava.util.logging.config.file=logging.properties
com.jannem.test.BasicTest

<...no log messages>

And ues, commons logging / Log4J would probably be less of a headache,
but that's not an option right now....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top