JDK-4506094 : LOGGING APIs: LogManager ignores java.util.logging.config.class
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2001-09-24
  • Updated: 2001-09-24
  • Resolved: 2001-09-24
Related Reports
Relates :  
Description

Name: elR10090			Date: 09/24/2001



The following test shows that LogManager ignores 
java.util.logging.config.class property and reads configuration from 
default file (jre/lib/logging.properties) during creation of LogManager 
instance.

The spec (Merlin-b80) from LogManager class says:

    In addition, the LogManager uses two optional system properties that 
    allow more control over reading the initial configuration: 

       "java.util.logging.config.class" 
       "java.util.logging.config.file" 
       
    These two properties may be set via the Preferences API, or as command 
    line property definitions to the "java" command, or as system property
    definitions passed to JNI_CreateJavaVM. 

    If the "java.util.logging.config.class" property is set, then the 
    property value is treated as a class name. The given class will be 
    loaded, an object will be instantiated, and that object's constructor 
    is responsible for reading in the initial configuration. (That object 
    may use other system properties to control its configuration.) 
    
    If "java.util.logging.config.class" property is *not* set, then the 
    "java.util.logging.config.file" system property can be used to specify 
    a properties file (in java.util.Properties format). The initial logging 
    configuration will be read from this file. 
    
The failure was observed on all platforms since Merlin-b70.    
    
See the test code and its output:    
    
import java.util.logging.*;
import java.io.*;

public class Test {
    static LogManager manager;
    static boolean wasHere = false;

    public static void main(String args[]) {
        System.setProperty("java.util.logging.config.class", "Test$Config");
        manager = LogManager.getLogManager(); 
        
        System.out.println("wasHere = " + wasHere);
    }

    public static class Config {
        public Config() {
            wasHere = true;
        }
    }
}

% .../jdk1.4.0beta-b69/solx86/bin/java -Xbootclasspath/a:. Test
wasHere = true
% .../jdk1.4.0beta-b70/solx86/bin/java -Xbootclasspath/a:. Test
wasHere = false
% .../jdk1.4.0beta-b80/solx86/bin/java -Xbootclasspath/a:. Test
wasHere = false

This bug affects the following test from testbase_nsk:

    nsk/logging/LogManager/readConfiguration/readcfg003
    
======================================================================

Comments
EVALUATION I think that what is happening here is actually correct. The LogManager is being initialized and is reading its configuration during Java startup before the "main" method is called. So setting the system property in the main method will have no affect. I ran the same test program, but defined the system property on the command line and it ran OK: java '-Djava.util.logging.config.class=Test$Config' Test wasHere = true Or alternatively you can change the test to do a manager.readConfiguration() call after setting the system property. This will cause the LogManager to re-read the configuration, using the new system property. Thanks, ###@###.### 2001-09-24
24-09-2001