Top Description Fields Constructors Methods
org.apache.logging.log4j.message

public Class LocalizedMessage

extends Object
implements Message, LoggerNameAwareMessage
Class Inheritance
All Implemented Interfaces
org.apache.logging.log4j.message.LoggerNameAwareMessage, org.apache.logging.log4j.message.Message, java.io.Serializable
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, java.util.Locale, .MissingResourceException, .ResourceBundle, org.apache.logging.log4j.status.StatusLogger

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.

Field Summary

Modifier and TypeField and Description
private transient Object[]
private String
private String
private String
private final Locale
private transient StatusLogger
private String
private transient ResourceBundle
private static final long
private String[]
private transient Throwable

Constructor Summary

AccessConstructor and Description
public
LocalizedMessage(final String
the message pattern that to be checked for placeholders.
messagePattern
,
final Object[]
the argument array to be converted.
arguments
)

Constructor with message pattern and arguments.

public
LocalizedMessage(final String baseName, final String key, final Object[] arguments)

public
LocalizedMessage(final ResourceBundle bundle, final String key, final Object[] arguments)

public
LocalizedMessage(final String baseName, final Locale locale, final String key, final Object[] arguments)

public
LocalizedMessage(final ResourceBundle bundle, final Locale locale, final String key, final Object[] arguments)

public
LocalizedMessage(final Locale locale, final String key, final Object[] arguments)

public
LocalizedMessage(final String messagePattern, final Object arg)

public
LocalizedMessage(final String baseName, final String key, final Object arg)

public
LocalizedMessage(final ResourceBundle bundle, final String key)

public
LocalizedMessage(final ResourceBundle bundle, final String key, final Object arg)

public
LocalizedMessage(final String baseName, final Locale locale, final String key, final Object arg)

public
LocalizedMessage(final ResourceBundle bundle, final Locale locale, final String key, final Object arg)

public
LocalizedMessage(final Locale locale, final String key, final Object arg)

public
LocalizedMessage(final String messagePattern, final Object arg1, final Object arg2)

public
LocalizedMessage(final String baseName, final String key, final Object arg1, final Object arg2)

public
LocalizedMessage(final ResourceBundle bundle, final String key, final Object arg1, final Object arg2)

public
LocalizedMessage(final String baseName, final Locale locale, final String key, final Object arg1, final Object arg2)

public
LocalizedMessage(final ResourceBundle bundle, final Locale locale, final String key, final Object arg1, final Object arg2)

public
LocalizedMessage(final Locale locale, final String key, final Object arg1, final Object arg2)

Method Summary

Modifier and TypeMethod and Description
public String
getFormat()

Implements org.apache.logging.log4j.message.Message.getFormat.

Gets the format portion of the Message.

public String

Returns:

The formatted message String.
getFormattedMessage
()

Implements org.apache.logging.log4j.message.Message.getFormattedMessage.

Returns the formatted message after looking up the format in the resource bundle.

public String

Returns:

the name of the Logger.
getLoggerName
()

Implements org.apache.logging.log4j.message.LoggerNameAwareMessage.getLoggerName.

Returns the name of the Logger.

public Object[]
getParameters()

Implements org.apache.logging.log4j.message.Message.getParameters.

Gets parameter values, if any.

protected ResourceBundle

Returns:

The ResourceBundle.
getResourceBundle
(final String
The base name of the resource bundle, a fully qualified class name.
rbBaseName
,
final Locale
The locale to use when formatting the message.
resourceBundleLocale
,
final boolean
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.
loop
)

Override this to use a ResourceBundle.Control in Java 6

public Throwable
private void
public void
setLoggerName(final String
The name of the Logger.
name
)

Implements org.apache.logging.log4j.message.LoggerNameAwareMessage.setLoggerName.

Set the name of the Logger.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

argArrayback to summary
private transient Object[] argArray
baseNameback to summary
private String baseName
formattedMessageback to summary
private String formattedMessage
keyback to summary
private String key
localeback to summary
private final Locale locale
loggerback to summary
private transient StatusLogger logger
loggerNameback to summary
private String loggerName
resourceBundleback to summary
private transient ResourceBundle resourceBundle
serialVersionUIDback to summary
private static final long serialVersionUID
stringArgsback to summary
private String[] stringArgs
throwableback to summary
private transient Throwable throwable

Constructor Detail

LocalizedMessageback to summary
public LocalizedMessage(final String messagePattern, final Object[] arguments)

Constructor with message pattern and arguments.

Parameters
messagePattern:String

the message pattern that to be checked for placeholders.

arguments:Object[]

the argument array to be converted.

LocalizedMessageback to summary
public LocalizedMessage(final String baseName, final String key, final Object[] arguments)
LocalizedMessageback to summary
public LocalizedMessage(final ResourceBundle bundle, final String key, final Object[] arguments)
LocalizedMessageback to summary
public LocalizedMessage(final String baseName, final Locale locale, final String key, final Object[] arguments)
LocalizedMessageback to summary
public LocalizedMessage(final ResourceBundle bundle, final Locale locale, final String key, final Object[] arguments)
LocalizedMessageback to summary
public LocalizedMessage(final Locale locale, final String key, final Object[] arguments)
LocalizedMessageback to summary
public LocalizedMessage(final String messagePattern, final Object arg)
LocalizedMessageback to summary
public LocalizedMessage(final String baseName, final String key, final Object arg)
LocalizedMessageback to summary
public LocalizedMessage(final ResourceBundle bundle, final String key)
Since
2.8
LocalizedMessageback to summary
public LocalizedMessage(final ResourceBundle bundle, final String key, final Object arg)
LocalizedMessageback to summary
public LocalizedMessage(final String baseName, final Locale locale, final String key, final Object arg)
LocalizedMessageback to summary
public LocalizedMessage(final ResourceBundle bundle, final Locale locale, final String key, final Object arg)
LocalizedMessageback to summary
public LocalizedMessage(final Locale locale, final String key, final Object arg)
LocalizedMessageback to summary
public LocalizedMessage(final String messagePattern, final Object arg1, final Object arg2)
LocalizedMessageback to summary
public LocalizedMessage(final String baseName, final String key, final Object arg1, final Object arg2)
LocalizedMessageback to summary
public LocalizedMessage(final ResourceBundle bundle, final String key, final Object arg1, final Object arg2)
LocalizedMessageback to summary
public LocalizedMessage(final String baseName, final Locale locale, final String key, final Object arg1, final Object arg2)
LocalizedMessageback to summary
public LocalizedMessage(final ResourceBundle bundle, final Locale locale, final String key, final Object arg1, final Object arg2)
LocalizedMessageback to summary
public LocalizedMessage(final Locale locale, final String key, final Object arg1, final Object arg2)

Method Detail

getFormatback to summary
public String getFormat()

Implements org.apache.logging.log4j.message.Message.getFormat.

Doc from org.apache.logging.log4j.message.Message.getFormat.

Gets the format portion of the Message.

Returns:String

The message format. Some implementations, such as ParameterizedMessage, will use this as the message "pattern". Other Messages may simply return an empty String. TODO Do all messages have a format? What syntax? Using a Formatter object could be cleaner. (RG) In SimpleMessage the format is identical to the formatted message. In ParameterizedMessage and StructuredDataMessage it is not. It is up to the Message implementer to determine what this method will return. A Formatter is inappropriate as this is very specific to the Message implementation so it isn't clear to me how having a Formatter separate from the Message would be cleaner.

Annotations
@Override
getFormattedMessageback to summary
public String getFormattedMessage()

Implements org.apache.logging.log4j.message.Message.getFormattedMessage.

Returns the formatted message after looking up the format in the resource bundle.

Returns:String

The formatted message String.

Annotations
@Override
getLoggerNameback to summary
public String getLoggerName()

Implements org.apache.logging.log4j.message.LoggerNameAwareMessage.getLoggerName.

Returns the name of the Logger.

Returns:String

the name of the Logger.

Annotations
@Override
getParametersback to summary
public Object[] getParameters()

Implements org.apache.logging.log4j.message.Message.getParameters.

Doc from org.apache.logging.log4j.message.Message.getParameters.

Gets parameter values, if any.

Returns:Object[]

An array of parameter values or null.

Annotations
@Override
getResourceBundleback to summary
protected ResourceBundle getResourceBundle(final String rbBaseName, final Locale resourceBundleLocale, final boolean loop)

Override this to use a ResourceBundle.Control in Java 6

Parameters
rbBaseName:String

The base name of the resource bundle, a fully qualified class name.

resourceBundleLocale:Locale

The locale to use when formatting the message.

loop:boolean

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:ResourceBundle

The ResourceBundle.

getThrowableback to summary
public Throwable getThrowable()

Implements org.apache.logging.log4j.message.Message.getThrowable.

Doc from org.apache.logging.log4j.message.Message.getThrowable.

Gets the throwable, if any.

Returns:Throwable

the throwable or null.

Annotations
@Override
readObjectback to summary
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException
setLoggerNameback to summary
public void setLoggerName(final String name)

Implements org.apache.logging.log4j.message.LoggerNameAwareMessage.setLoggerName.

Set the name of the Logger.

Parameters
name:String

The name of the Logger.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
writeObjectback to summary
private void writeObject(final ObjectOutputStream out) throws IOException