Package org.apache.logging.log4j.message
Class LocalizedMessage
java.lang.Object
org.apache.logging.log4j.message.LocalizedMessage
- All Implemented Interfaces:
Serializable,LoggerNameAwareMessage,Message
Provides some level of compatibility with Log4j 1.x and convenience but is not the recommended way to Localize
messages.
The recommended way to localize messages is to log a message id. Log events should then be recorded without formatting into a data store. The application that is used to read the events and display them to the user can then localize and format the messages for the end user.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLocalizedMessage(String messagePattern, Object arg) LocalizedMessage(String messagePattern, Object[] arguments) Constructor with message pattern and arguments.LocalizedMessage(String messagePattern, Object arg1, Object arg2) LocalizedMessage(String baseName, String key, Object arg) LocalizedMessage(String baseName, String key, Object[] arguments) LocalizedMessage(String baseName, String key, Object arg1, Object arg2) LocalizedMessage(String baseName, Locale locale, String key, Object arg) LocalizedMessage(String baseName, Locale locale, String key, Object[] arguments) LocalizedMessage(Locale locale, String key, Object arg) LocalizedMessage(Locale locale, String key, Object[] arguments) LocalizedMessage(Locale locale, String key, Object arg1, Object arg2) LocalizedMessage(ResourceBundle bundle, String key) LocalizedMessage(ResourceBundle bundle, String key, Object arg) LocalizedMessage(ResourceBundle bundle, String key, Object[] arguments) LocalizedMessage(ResourceBundle bundle, String key, Object arg1, Object arg2) LocalizedMessage(ResourceBundle bundle, Locale locale, String key, Object arg) LocalizedMessage(ResourceBundle bundle, Locale locale, String key, Object[] arguments) LocalizedMessage(ResourceBundle bundle, Locale locale, String key, Object arg1, Object arg2) -
Method Summary
Modifier and TypeMethodDescriptionThis method has unclear semantics and inconsistent implementations – its usage is strongly discouraged.Returns the formatted message after looking up the format in the resource bundle.Returns the name of the Logger.Object[]Gets parameter values, if any.protected ResourceBundlegetResourceBundle(String rbBaseName, Locale resourceBundleLocale, boolean loop) Override this to use a ResourceBundle.Control in Java 6Gets the throwable, if any.voidsetLoggerName(String name) Set the name of the Logger.toString()
-
Constructor Details
-
LocalizedMessage
Constructor with message pattern and arguments.- Parameters:
messagePattern- the message pattern that to be checked for placeholders.arguments- the argument array to be converted.
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
- Since:
- 2.8
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
LocalizedMessage
-
-
Method Details
-
setLoggerName
Set the name of the Logger.- Specified by:
setLoggerNamein interfaceLoggerNameAwareMessage- Parameters:
name- The name of the Logger.
-
getLoggerName
Returns the name of the Logger.- Specified by:
getLoggerNamein interfaceLoggerNameAwareMessage- Returns:
- the name of the Logger.
-
getFormattedMessage
Returns the formatted message after looking up the format in the resource bundle.- Specified by:
getFormattedMessagein interfaceMessage- Returns:
- The formatted message String.
-
getFormat
Description copied from interface:MessageThis method has unclear semantics and inconsistent implementations – its usage is strongly discouraged. -
getParameters
Description copied from interface:MessageGets parameter values, if any.- Specified by:
getParametersin interfaceMessage- Returns:
- An array of parameter values or null.
-
getThrowable
Description copied from interface:MessageGets the throwable, if any.- Specified by:
getThrowablein interfaceMessage- Returns:
- the throwable or null.
-
getResourceBundle
protected ResourceBundle getResourceBundle(String rbBaseName, Locale resourceBundleLocale, boolean loop) Override this to use a ResourceBundle.Control in Java 6- Parameters:
rbBaseName- The base name of the resource bundle, a fully qualified class name.resourceBundleLocale- The locale to use when formatting the message.loop- If true the key will be treated as a package or class name and a resource bundle will be located based on all or part of the package name. If false the key is expected to be the exact bundle id.- Returns:
- The ResourceBundle.
-
toString
-