aspose file tools
The moose likes Java in General and the fly likes Can one set System property programmatically? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Can one set System property programmatically?" Watch "Can one set System property programmatically?" New topic
Author

Can one set System property programmatically?

Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
I can set up system property at command line (note that test2 is the package name)
C:\mrcgui>java -Djava.util.logging.config.file=test2/mylog.properties test2.TestLogging
It works. But when I try to set property in the code, it never worked.
=== code ==
System.setProperty("java.util.logging.config.file", "test2/mylog.properties");
pf = System.getProperty("java.util.logging.config.file");
System.out.println("pf=" +pf); //prints test2/mylog.properties
Logger logger = Logger.getLogger("test2");
=== end of code ===
The logger still uses the default logger.
Why?
Thanks.


BJ - SCJP and SCWCD
We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
It probably initialized from the system property before you reset it.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Can one set System property programmatically?
 
Similar Threads
question about java logging.
Specify custom logging.properties file in the a Java program.
JVM Options - How are paths set?
How to set a custom logger property file in Tomcat?
How to set a system property in a web app?