Class LocalizedMessage

All Implemented Interfaces:
Serializable, LoggerNameAwareMessage, Message

public class LocalizedMessage extends Object implements Message, LoggerNameAwareMessage
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 Details

  • Method Details

    • setLoggerName

      public void setLoggerName(String name)
      Set the name of the Logger.
      Specified by:
      setLoggerName in interface LoggerNameAwareMessage
      name - The name of the Logger.
    • getLoggerName

      public String getLoggerName()
      Returns the name of the Logger.
      Specified by:
      getLoggerName in interface LoggerNameAwareMessage
      the name of the Logger.
    • getFormattedMessage

      public String getFormattedMessage()
      Returns the formatted message after looking up the format in the resource bundle.
      Specified by:
      getFormattedMessage in interface Message
      The formatted message String.
    • getFormat

      public String getFormat()
      Description copied from interface: Message
      Gets the format portion of the Message.
      Specified by:
      getFormat in interface Message
      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.
    • getParameters

      public Object[] getParameters()
      Description copied from interface: Message
      Gets parameter values, if any.
      Specified by:
      getParameters in interface Message
      An array of parameter values or null.
    • getThrowable

      public Throwable getThrowable()
      Description copied from interface: Message
      Gets the throwable, if any.
      Specified by:
      getThrowable in interface Message
      the throwable or null.
    • getResourceBundle

      protected ResourceBundle getResourceBundle(String rbBaseName, Locale resourceBundleLocale, boolean loop)
      Override this to use a ResourceBundle.Control in Java 6
      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.
      The ResourceBundle.
    • toString

      public String toString()
      toString in class Object