Java: How to change the language of java.util.logging to English?
Asked Answered
E

1

5

I have java.util.logging to print output to a file. It works fine. However, the messages contain chinese characters which correspond to the log level and the time the messages are logged.

How can I make it print english instead of chinese characters ?

This is what the current messages look like

11月 08, 2016 8:28:03 下午 mySamples.testing.TestingFile errorFunction
資訊: Exception: 123
Evadnee answered 8/11, 2016 at 12:21 Comment(1)
you can use Locale.setDefault(Locale.ENGLISH); to change the log level languagesSubmiss
N
8

Start your application by passing the language on the command-line to override the current default language of the OS.

java -Duser.language=en MyApplication
Neuropathy answered 8/11, 2016 at 12:34 Comment(5)
Is there a way that I override it permanently ? I am using Eclipse to compile and run the applcation.Evadnee
You can define an environment variable called _JAVA_OPTIONS=-Duser.language=en to make it the default value for the JVM.Neuropathy
If you want to set it programmatically, you can put System.setProperty("user.language", "en") in a static block at the beginning of your main class (class containing the main method)Tho
interesting blog post about it blogs.oracle.com/CoreJavaTechTips/entry/…Tho
Locale.setDefault(new Locale("en", "EN")); works for me (and System.setProperty does not).Swearingen

© 2022 - 2024 — McMap. All rights reserved.