|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object mazz.i18n.LoggerLocale
public class LoggerLocale
A utility that provides a locale that you can use for your loggers. Sometimes, you want your log messages to be logged in one locale while your user interfaces use another locale. For example, a customer may be running in a German locale, however, the team that supports the software may be located in France and only speaks and reads French. Therefore, they will want to see the logs dumped in French so they can read the logs and help decipher problems that their German customer is having.
This class provides a method (getLogLocale()
)to give you the locale that your log messages should be
logged with. It may or may not be different than the JVM's default locale.
To define a separate log locale, this class looks for a system property called
i18nlog.log-locale
. It must be in the form of "language_country_variant" where country and variant are
optional. For example, the system property can be "it", "en_US" or "fr_FR_EURO".
If you want the log locale to be the same as the default VM locale, set the system property
i18nlog.log-locale-is-default
to true
. This will be ignored if the
i18nlog.log-locale
system property is set.
If neither system property is set, the log locale is set to Locale.ENGLISH
.
You can also programatically set the locale via the methods setLogLocale(Locale)
or
setLogLocale(String)
.
This utility is a singleton. If you change the system properties during runtime and wish for this singleton
to pick up the change (and thus change its log locale value), you must call reset()
after the change in
system properties is made. It is preferrable to call one of the setter methods to affect a change rather that
using the system properties.
Locale
Field Summary | |
---|---|
static java.lang.String |
LOG_LOCALE_IS_DEFAULT_SYSTEM_PROPERTY
If this system property is set to true , the log locale will be set to the same as the default
JVM locale. |
static java.lang.String |
LOG_LOCALE_SYSTEM_PROPERTY
The name of the system property that contains the log locale. |
Constructor Summary | |
---|---|
LoggerLocale()
|
Method Summary | |
---|---|
static java.util.Locale |
getLogLocale()
If the log locale has not been set yet, this will examines the system properties LOG_LOCALE_SYSTEM_PROPERTY and LOG_LOCALE_IS_DEFAULT_SYSTEM_PROPERTY to determine what the
log locale should be. |
static void |
reset()
Resets what this class thinks should be the log locale. |
static void |
setLogLocale(java.util.Locale locale)
This method allows you to explicitly define what locale all loggers should use when logging messages. |
static void |
setLogLocale(java.lang.String locale_str)
Parses the locale string, which must be in the form of "language_country_variant" where country and variant are optional, and returns that locale. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String LOG_LOCALE_SYSTEM_PROPERTY
public static final java.lang.String LOG_LOCALE_IS_DEFAULT_SYSTEM_PROPERTY
true
, the log locale will be set to the same as the default
JVM locale.
Constructor Detail |
---|
public LoggerLocale()
Method Detail |
---|
public static java.util.Locale getLogLocale()
LOG_LOCALE_SYSTEM_PROPERTY
and LOG_LOCALE_IS_DEFAULT_SYSTEM_PROPERTY
to determine what the
log locale should be.
public static void setLogLocale(java.util.Locale locale)
locale
- the new localepublic static void setLogLocale(java.lang.String locale_str)
locale_str
is null
, then
Locale.ENGLISH
is returned. If you want the default VM to be used as the new log locale, call
setLogLocale
(Locale.getDefault()).
locale_str
- the locale string in the form of "language_country_variant" or null
public static void reset()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |