BEA WebLogic Server User Manual

Page 69

Advertising
background image

Example of a Generated Logger Class

Internationalization Guide

B-7

import java.util.Locale;

import weblogic.i18n.Localizer;
import weblogic.i18ntools.L10nLookup;
import weblogic.logging.Loggable;

/**
* @author Copyright (c) 2000 by BEA Systems, Inc. All Rights Reserved.
*/

/**
* This example shows how to use the internationalized (I18n) logging interfaces.
* <p>
* usage: java examples.i18n.logging.I18nLog
* <p>
* Build procedure: run bld.sh (UNIX) or bld.cmd (NT). These scripts
* process the I18nLog.xml catalog, producing the logging class,
* <tt>examples.i18n.logging.I18nLogLogger</tt>. This class contains static
methods
* for logging messages to the WLS error log. The methods and arguments are
* defined in the I18nLog.xml catalog. This example also uses a simple
* message catalog, I18nSimple.xml.
*/

public class I18nLog {

public I18nLog() {}

public static void main(String[] argv) {
/**
* This call just logs an info message. There are no arguments defined
* for this method.
*
* This also shows how to use the Loggable form of the method.
*/

Loggable ll = I18nLogLogger.logEntryLoggable();
ll.log();
System.out.println(ll.getMessage());

/**
* Here's an example of a message including a variety
* of arguments.
*/
I18nLogLogger.testArgs(I18nLog.class.getName(),argv.length);
/**
* If a Throwable is passed then it will result in a stack trace
* being logged along with the method by default.

Advertising