Configure all log handlers to use UTF-8 instead of the JVM's default encoding.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2552 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
package com.samskivert.util;
|
package com.samskivert.util;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.logging.Handler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,6 +38,20 @@ public class JDK14Logger implements Logger.Factory
|
|||||||
if (!Boolean.getBoolean("com.samskivert.util.JDK14Logger.noFormatter")) {
|
if (!Boolean.getBoolean("com.samskivert.util.JDK14Logger.noFormatter")) {
|
||||||
OneLineLogFormatter.configureDefaultHandler();
|
OneLineLogFormatter.configureDefaultHandler();
|
||||||
}
|
}
|
||||||
|
boolean reportedUTF8Missing = false;
|
||||||
|
for (Handler handler : java.util.logging.Logger.getLogger("").getHandlers()) {
|
||||||
|
try {
|
||||||
|
handler.setEncoding("UTF-8");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
// JVMs are required to support UTF-8 so this shouldn't happen, but if it does,
|
||||||
|
// tell somebody that things are really fucked
|
||||||
|
if (!reportedUTF8Missing) {
|
||||||
|
reportedUTF8Missing = true;
|
||||||
|
System.err.println("Unable to find UTF-8 encoding. " +
|
||||||
|
"This JVM ain't right: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (SecurityException se) {
|
} catch (SecurityException se) {
|
||||||
// running in sandbox; no custom logging; no problem!
|
// running in sandbox; no custom logging; no problem!
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user