Results 1 to 3 of 3
- 03-22-2009, 03:39 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 7
- Rep Power
- 0
Java logging - log file location for FileHandler
Hello,
All logging configurations for my logger are taken from a logging.properties file, but I'd like to set the FileHandler's log file directory after loading the properties file. This is because the directory name is loaded from another properties file (called config.properties).
I understand that the directory is part of the file name specified by "java.util.logging.FileHandler.pattern" property in the properties file, but I'd like to change that, without changing the logging.properties file for every run.
How can the LogManager's properties be changed, once loaded using readConfiguration(InputStream) function?
There is no logMan.setProperty() method or anything similar...
Thanks
Kfir
- 03-24-2009, 07:08 AM #2
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
While you can't dynamically change properties, you can change your logging Handlers programatically to override the properties.
Java Code:Logger logger = .... Handler[] handlers = logger.getHandlers(); for(Handler h : handlers) { if(h instanceof FileHandler) logger.removeHandler(h); } FileHandler fh = new FileHandler(...); ...alter logging default level, formatter, etc if desired... logger.addHandler(fh);
- 03-24-2009, 08:22 AM #3
Member
- Join Date
- Mar 2009
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Loading Java plugin from a specified location on client's disk?
By khermans in forum Advanced JavaReplies: 1Last Post: 03-05-2009, 11:40 PM -
Location of java class libraries on Sun
By phudgens in forum New To JavaReplies: 3Last Post: 02-05-2009, 04:45 AM -
Java Extract PDF data from location XY
By Unite in forum Advanced JavaReplies: 1Last Post: 06-30-2008, 01:31 PM -
Java Logging
By vaswin in forum Advanced JavaReplies: 0Last Post: 08-06-2007, 01:18 PM -
Java Logging
By vignesh in forum Advanced JavaReplies: 3Last Post: 08-03-2007, 09:52 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks