JDK-8028233 : Logging prints timestamp in US format only, whatever the locale is.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.logging
  • Affected Version: 7u25
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_7
  • Submitted: 2013-11-06
  • Updated: 2014-04-09
  • Resolved: 2014-04-09
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
The Java Logging system ignores the locale and always uses en_US.

REGRESSION.  Last worked in version 6u43

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set your locale not non-US, e.g. de_DE

public static void main(String[] args) {

System.out.println(Locale.getDefault());

Logger logger = Logger.getAnonymousLogger();
logger.warning("I am wrong");

}

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
de_DE
<<log message>> with German date format
ACTUAL -
de_DE
Nov 06, 2013 1:22:29 PM ojdbctest.HelloServlet main
WARNING: I am wrong


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public static void main(String[] args) {

System.out.println(Locale.getDefault());

Logger logger = Logger.getAnonymousLogger();
logger.warning("I am wrong");

}
---------- END SOURCE ----------
Comments
The major issue the original bug referred to has been fixed (levels are translated correctly). There's a however a slight behavior change due to the fact that the new overridable format strings is expressed in the syntax defined by http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax - which as no equivalent for the previous {0,date} {0,time} behavior. So we lost the ability to decide on 24hour vs 12hour time depending on the locale, but we gained the ability to override the default format by providing a format string for the java.util.logging.SimpleFormatter.format property in logging.properties. See JDK-6381464 for more details.
09-04-2014

Further evaluation shows that the locale is taken into account, it's just that the conversion is different to what it was before: The default format now is: "%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%6$s%n" (see http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax) It is possible to override that by providing a value for java.util.logging.SimpleFormatter.format in the logging.properties file. For instance: java.util.logging.SimpleFormatter.format=%1$tb %1tA %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%6$s%n (notice the additional %1tA) which gives: Apr Mittwoch 09, 2014 4:08:58 PM dummy.Dummy main INFORMATION: second Apr Mittwoch 09, 2014 4:08:58 PM dummy.Dummy main INFORMATION: fourth dummy.Dummy Apr Mittwoch 09, 2014 4:08:58 PM dummy.Dummy main SCHWERWIEGEND: last for Locale.setDefault(Locale.GERMAN); Logger.getLogger("foo.bar.baz").fine("first"); Logger.getLogger("foo.bar.baz").info("second"); Logger.getLogger("global").info("third"); Logger.getLogger("foo.bar.baz").info(() -> "fourth " + Dummy.class.getName()); Logger.getLogger("global").severe("last"); So this is not a bug - it is however - a behaviour change. A workaround to get back the old behaviour could be to declare your own custom formater in logging.properties.
09-04-2014

In 5 & 6, the date & time format for Locale = "de" was: 12.11.2013 17:53:10 In 7 it became: Nov 12, 2013 5:53:10 PM (which is the same than is printed for Locale = "en"). This looks like a regression introduced by JDK-6381464. Workaround: it should be possible to change the date format by specifying the a format string through the "java.util.logging.SimpleFormatter.format" system property.
12-11-2013