Operating Systems: i5/OS
             Personalize the table of contents and search results

 

Create log resource bundles and message files

 

You can forward messages that are written to the internal WebSphere Application Server logs to other processes for display. Messages that are displayed on the administrative console, which can be running in a different location than the server process, can be localized using the late binding process. Late binding means that WebSphere Application Server does not localize messages when they are logged, but defers localization to the process that displays the message.

 

Overview

Every method that accepts messages localizes those messages. The mechanism for providing localized messages is the resource bundle support provided by the IBM Developer Kit, Java Technology Edition. If you are not familiar with resource bundles as implemented by the Developer Kit, you can get more information from various texts, or by reading the API documentation for the java.util.ResourceBundle, java.util.ListResourceBundle and java.util.PropertyResourceBundle classes, as well as the java.text.MessageFormat class.

The PropertyResourceBundle class is the preferred mechanism to use.

To properly localize the message, the displaying process must have access to the resource bundle where the message text is stored. You must package the resource bundle separately from the application, and install it in a location where the viewing process can access it.

By default, the WebSphere Application Server runtime localizes all the messages when they are logged. This localization eliminates the need to pass a .jar file to the application, unless you need to localize in a different location. However, you can use the early binding technique to localize messages as they log. An application that uses early binding must localize the message before logging it. The application looks up the localized text in the resource bundle and formats the message. Use the early binding technique to package the application resource bundles with the application.

To create a resource bundle, perform the following steps.

 

Procedure

  1. Create a text properties file that lists message keys and the corresponding messages. The properties file must have the following characteristics:

    See the Java documentation for the java.util.Properties class for a full description of the syntax and the construction of properties files.

  2. Translate the file into localized versions of the file with language-specific file names. For example, a file named DefaultMessages.properties can be translated into DefaultMessages_de.properties for German and DefaultMessages_ja.properties for Japanese.

  3. When the translated resource bundles are available, put the bundle in a directory that is part of the application class path.

  4. When a message logger is obtained from the log manager, configure it to use a particular resource bundle. Messages logged with the Logger API use this resource bundle when message localization is performed. At run time, the user locale setting determines the properties file from which to extract the message that is specified by a message key, ensuring that the message is delivered in the correct language.

  5. If the message loggers msg method is called, a resource bundle name must be explicitly provided.

 

What to do next

The application locates the resource bundle based on the file location relative to any directory in the class path. For instance, if the DefaultMessages.properties property resource bundle is located in the baseDir/subDir1/subDir2/resources directory and baseDir is in the class path, the name subdir1.subdir2.resources.DefaultMessage is passed to the message logger to identify the resource bundle.


}
Example: Logging resource bundles by creating a properties file