BEA WebLogic Server User Manual

Page 70

Advertising
background image

B

Logger Class Reference for BEA WebLogic Server

B-8

Internationalization Guide

*/
Throwable t = new Throwable("Test with stack trace");
I18nLogLogger.logTrace(t);
/**
* Messages can optionally be defined to not log a stack trace.
*/
I18nLogLogger.logNoTrace(t);
/**
* The logger methods return the messageid for applications
* that want to do more than just log these messages.
*/
String messageId = I18nLogLogger.getId();
I18nLogLogger.showId(messageId);
/**
* the message id can be used to obtain the different attributes
* of a message. The L10nLookup object provides access to the catalogs
* via Localizer classes. Localizers provide the access to individual
* messages. Each log message catalog has two Localizers: one for
* general message information and one for the detailed attributes.
*
* The basic Localizer provides access to catalog information:
* Version
* L10n Package - package for catalog data
* I18n Package - package for Logger methods
* Subsystem - catalog subsystem
* For each message it also provides:
* Severity: debug (128), info (64), warning (32), error (8)
* Message Body - the message text
* Stack option - whether to log a stack trace
*
* First get to the L10nLookup properties, then use them to get the
* Localizer's for the message.
*/
L10nLookup l10n = L10nLookup.getL10n();
/**
* This returns the basic Localizer (arg 3 = false)
*/
Localizer lcl = l10n.getLocalizer(messageId,Locale.getDefault(),false);
/**
* This returns the detailed Localizer (arg 3 = true)
*/
Localizer lclDetail = l10n.getLocalizer(messageId,Locale.getDefault(),true);
/**
* Use this appplications simple message catalog to display the
* log message catalog information
*/
I18nSimpleTextFormatter fmt = new I18nSimpleTextFormatter();
System.out.println(fmt.version(messageId,lcl.getVersion()));
System.out.println(fmt.l10nPackage(messageId,lcl.getL10nPackage()));

Advertising