JDK-8007611 : logging behavior in applet changed
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.logging
  • Affected Version: 7u13
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-02-06
  • Updated: 2013-09-12
  • Resolved: 2013-02-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7 JDK 8 Other
1.4.2_42,OpenJDK6Fixed 6u41Fixed 7u15Fixed 8 b02Fixed OpenJDK6Fixed
Description
the following code works 7u11 as applet:

import java.applet.Applet;
import java.util.logging.*;

public class Hello extends Applet {

      private static final Logger log = Logger.getLogger("Hello");

   @Override
   public void init() {
      log.info("Hello!!");
      System.out.println("mmmhhhh....");
   }
   // TODO overwrite start(), stop() and destroy() methods
}


Java console would show output:

05-feb-2013 11:18:50 Hello init
INFO: Hello!!


With 7u13 - it does not output in java console
Comments
Workaround: set -Djava.util.logging.config.file=<jre>/lib/logging.properties via Java control panel. This will workaround the logging initialization issue. Thomas has kindly helped verify that this workaround works with 7u13.
06-02-2013

Suggested fix on LogManager: diff --git a/src/share/classes/java/util/logging/LogManager.java b/src/share/classes/java/util/logging/LogManager.java --- a/src/share/classes/java/util/logging/LogManager.java +++ b/src/share/classes/java/util/logging/LogManager.java @@ -363,6 +363,7 @@ context = userContext; } else { context = new LoggerContext(); + if (manager.rootLogger != null) context.addLocalLogger(manager.rootLogger); } javaAwtAccess.put(ecx, LoggerContext.class, context); this NPE will be thrown only when creating the rootLogger during initialization. After that rootLogger can be added to the user context. Also the global handlers for the rootLogger is reinitialized the first time it is accessed (due to the LogManager and Logger initialization dependency) For jdk8, I'll add a system property for testing purpose if set it will throw the exception during initialization instead of silently ignore it.
06-02-2013

Logging initialization is fragile and complex. The worst is that it ignores all exception silently. I can agree that error in logging should not impact the application runtime but ignoring error during logging initialization makes bugs to creep in and hard to diagnose. LogManager.readPrimordialConfiguration fails with NPE as it's called during LogManager.<clinit>. Can't read logging configuration: java.lang.NullPointerException at java.util.logging.LogManager$LoggerContext.addLocalLogger(LogManager.java:502) at java.util.logging.LogManager.getUserContext(LogManager.java:366) at java.util.logging.LogManager.contexts(LogManager.java:380) at java.util.logging.LogManager.reset(LogManager.java:1014) at java.util.logging.LogManager.readConfiguration(LogManager.java:1094) at java.util.logging.LogManager.readConfiguration(LogManager.java:987) at java.util.logging.LogManager$2.run(LogManager.java:288) at java.util.logging.LogManager$2.run(LogManager.java:286) at java.security.AccessController.doPrivileged(Native Method) at java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:286) at java.util.logging.LogManager.getLogManager(LogManager.java:268) at java.util.logging.Logger.<init>(Logger.java:252) at java.util.logging.LogManager$RootLogger.<init>(LogManager.java:1320) at java.util.logging.LogManager$RootLogger.<init>(LogManager.java:1318) at java.util.logging.LogManager$1.run(LogManager.java:199) at java.security.AccessController.doPrivileged(Native Method) at java.util.logging.LogManager.<clinit>(LogManager.java:176) at java.util.logging.Logger.demandLogger(Logger.java:307) at java.util.logging.Logger.getLogger(Logger.java:370) at Hello.<clinit>(Hello.java:6) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java: 57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorIm pl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at java.lang.Class.newInstance0(Class.java:374) at java.lang.Class.newInstance(Class.java:327) at sun.applet.AppletPanel.createApplet(AppletPanel.java:793) at sun.applet.AppletPanel.runLoader(AppletPanel.java:722) at sun.applet.AppletPanel.run(AppletPanel.java:379) at java.lang.Thread.run(Thread.java:722)
06-02-2013

when it works, I see the following: In Java Console: Feb 05, 2013 7:35:47 PM HelloWorld init INFO: Hello!! In log output file: <record> <date>2013-02-05T19:35:47</date> <millis>1360121747246</millis> <sequence>3</sequence> <logger>sun.plugin</logger> <level>FINE</level> <class>com.sun.deploy.trace.LoggerTraceListener</class> <method>print</method> <thread>8</thread> <message>Feb 05, 2013 7:35:47 PM HelloWorld init INFO: Hello!! </message> </record>
06-02-2013

original report: http://stackoverflow.com/questions/14705326/java-applet-logging-7u13
06-02-2013

I can reproduce the problem with 7u13. I checked the deployment fixes in 7u13 - don't see anything that is related to loggin. I then tried to replace the rt.jar in 7u13 with copy from 7u11 - it works. Is there some fix related to logging API in 7u13 that might caused this ?
06-02-2013