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

Logging not performed in 1.7 unless root handler

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b55)
      Java HotSpot(TM) Client VM (build 15.0-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]
      Linux xxx 2.6.18-92.1.22.el5 #1 SMP Fri Dec 5 09:29:46 EST 2008 i686 i686 i386 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Logger.getLogger(Test1.class.getName()).log(Level.SEVERE, "Logged ONE") does not, by default, display message on console.

      Adding a call to (any) method on the root logger will then cause SEVERE errors to be logged (see "Steps to reproduce" blow).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please run the following program

      C:\tmp>type Test1.java
      import java.util.logging.Level;
      import java.util.logging.LogManager;
      import java.util.logging.Logger;

      public class Test1
      {
        public static void main(String[] args) throws Exception
        {
          Logger.getLogger(Test1.class.getName()).log(Level.SEVERE, "Logged ONE");
          LogManager.getLogManager().getLogger("").getHandlers();
          Logger.getLogger(Test1.class.getName()).log(Level.SEVERE, "Logged TWO");
        }
      }


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Both logs should have been displayed.
      ACTUAL -
      Only "Logged TWO" is displayed with jdk1.7.0ea

      (On 1.6 both lines are correctly output)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.logging.Level;
      import java.util.logging.LogManager;
      import java.util.logging.Logger;

      public class Test1
      {
        public static void main(String[] args) throws Exception
        {
          Logger.getLogger(Test1.class.getName()).log(Level.SEVERE, "Logged ONE");
          LogManager.getLogManager().getLogger("").getHandlers();
          Logger.getLogger(Test1.class.getName()).log(Level.SEVERE, "Logged TWO");
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Put in the call to LogManager.getLogManager().getLogger("").getHandlers();

      Release Regression From : 6u12
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            jgish Jim Gish (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: