Using message arguments, Listing 2-1 example of message arguments, Using message arguments -4 – BEA WebLogic Server User Manual

Page 22

Advertising
background image

2

Using Message Catalogs with BEA WebLogic Server

2-4

Internationalization Guide

„

Java allows you to group classes into a collection called a package. A package
name should be consistent with the name of the subsystem in which a particular
catalog resides.

„

The log Localizer “classes” are actually

ResourceBundle

property files.

Using Message Arguments

The message body, message detail, cause, and action sections of a log message can
include message arguments, as described by

java.text.MessageFormat

. Only the

message body section in a simple message can include arguments. Arguments are
values that can be dynamically set at runtime. These values are passed to routines, such
as printing out a message. A message can support up to 10 arguments, numbered 0-9.
You can include any subset of these arguments in any text section of the message
definition, although the message body should include all of the arguments. You insert
message arguments into a message definition during development, and these
arguments are replaced by the appropriate message content at runtime when the
message is logged.

The following excerpt from an XML log message definition shows how you can use
message arguments. The argument number must correspond to one of the arguments
specified in the

method

attribute. Specifically,

{0}

with the first argument,

{1}

with

the second, and so on.

Listing 2-1 Example of Message Arguments

<messagebody>Unable to open file, {0}.</messagebody>
<messagedetail>
File, {0} does not exist. The server will restore the file
contents from {1}, resulting in the use of default values
for all future requests.
</messagedetail>
<cause>The file was deleted</cause>
<action>
If this error repeats then investigate unauthorized access to
the file system.
</action>

Advertising