Name: elR10090 Date: 07/19/2001
The following is the current (from Merlin-b70) specification for the method
java.util.logging.LogManager.getProperty(String).
public String getProperty(String name)
Get the value of a logging property.
Parameters: name - property name
Returns: property value
The spec does not specify what value will be returned if the property is not
found.
Since all logging properties are stored in java.util.Properties format let us
check this situation in java.util.Properties class.
Spec for the method Properties.getProperty(String)
public String getProperty(String key)
Searches for the property with the specified key in this property list.
If the key is not found in this property list, the default property list,
and its defaults, recursively, are then checked. The method returns null
if the property is not found.
Parameters: key - the property key.
Returns: the value in this property list with the specified key value.
says that null will be returned "if the property is not found". Please, note,
the
same behavior (the method returns null if property is not found) is specified in
java.lang.System.getProperty(String).
I believe the same remark should be documented in the
LogManager.getProperty(String)
method.
The following test shows that LogManager.getProperty(String) returns
null if the property is not found with the given name.
import java.util.logging.*;
import java.io.*;
public class Test {
final static LogManager logManager = LogManager.getLogManager();
public static void main (String args[]) {
System.exit(95 + run(args, System.out));
}
public static int run(String args[], PrintStream out) {
String property1;
String property2;
property1 = logManager.getProperty("");
out.println("# Property 1 is " + property1);
property2 = logManager.getProperty("NO_SUCH_PROPERTY");
out.println("# Property 2 is " + property2);
return 0;
}
}
The test outputs
# Property 1 is null
# Property 2 is null
======================================================================