-
Enhancement
-
Resolution: Future Project
-
P4
-
None
-
1.4.1
-
x86
-
windows_2000
Name: rmT116609 Date: 01/30/2003
DESCRIPTION OF THE PROBLEM :
In java.util.logging.LogManager there is a method readConfiguration(InputStream is) that reads properties in the form of java.util.Properties. Often, I have a Properties object already in memory, for example, when a servlet (loaded at startup) reads all the configuration data for the entire webapp from an XML file. Now I have to store the Properties object in a ByteArrayOutputStream and feed a ByteArrayInputStream to LogManager.readConfiguration(InputStream is). This works, but is not very elegant. To me, a
LogManager.readConfiguration(Properties p) seems a logical enhancement to the Logging API.
---------- BEGIN SOURCE ----------
public static void configure(Properties p) {
java.util.logging.LogManager.getLogManager().readConfiguration(p);
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
public static void configure(Properties p) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
ByteArrayInputStream is;
byte[] buf;
try {
p.store(os, "logging");
buf = os.toByteArray();
is = new ByteArrayInputStream(buf);
java.util.logging.LogManager.getLogManager().readConfiguration(is);
} catch(IOException e) {
System.out.println("ERROR: Failed to configure
java.util.logging.LogManager");
}
}
(Review ID: 180570)
======================================================================