Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8023163

Logger hierarchy inconsistent with applets

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • tbd
    • 7u13
    • core-libs

      FULL PRODUCT VERSION :
      Java(TM) SE Runtime Environment (build 1.7.0_25-b17)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]
      (not relevant)

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      not relevant for reproducing the issue

      A DESCRIPTION OF THE PROBLEM :
      The logger hierachy gets inconsistent between " systemContext " and " userContext " . While setting the log level at the root logger programmatically to " FINEST " is propagated to all children, setting the " java.awt " node to " INFO " afterwards shows no effect in an applet context, " java.awt.* " loggers still log at " FINEST " .

      The reason for this seems to be that hierarchy construction only takes into account the loggers from the respective context.

      While the below code works in a plain app, in a (signed) applet is does not.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Code below not working in a browser environment with separate logging user contexts

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Logging for events in all child nodes of " java.awt " should be disabled when level below INFO.
      ACTUAL -
      Logging for events in child nodes of " java.awt " is still FINEST.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.logging.FileHandler;
      import java.util.logging.Handler;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      import java.util.logging.SimpleFormatter;

      import javax.swing.JApplet;
      import javax.swing.JLabel;

      public class HelloWorldApplet extends JApplet {

      @Override
      public void init() {
      super.init();

      // Add the ubiquitous " Hello World " label.
      JLabel label = new JLabel( " Hello World " );
      add(label);

      try {

      // just to make readable
      System.setProperty( " java.util.logging.SimpleFormatter.format " ,
       " [%3$s][%4$s][%5$s]%n " );
      Handler handler = new FileHandler( " %h/test.log " );
      handler.setLevel(Level.FINEST);
      handler.setFormatter(new SimpleFormatter());
      Logger.getLogger( " " ).addHandler(handler);

      // this is the " real issue " *******************************
      Logger.getLogger( " " ).setLevel(Level.FINEST);
      Logger.getLogger( " java.awt " ).setLevel(Level.INFO);
      Logger.getLogger( " sun.awt " ).setLevel(Level.INFO);
      // ********************************************************

      } catch (Exception e) {
      //
      }

      Logger.getLogger( " my.logger " ).log(Level.FINEST, " now ui is visible " );
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No idea. One must either look up potential children in all contexts or eager create parent nodes.

            dfuchs Daniel Fuchs
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: