Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

WebLogic Server 8.1 API Reference

## weblogic.logging
Class Loggable

    java.lang.Object
      |
      +--weblogic.logging.Loggable

public class Loggable
extends java.lang.Object

Loggable objects are used when there is a need to collect log entry data without actually logging the message until a later time. Type casting is weak for the log parameters provided when constructing. The user must ensure that the arguments associated with a particular log message are of the appropriate type and in the correct order.

It is therefore preferable to not explicitly create Loggable objects, rather they should be defined through the relevant message catalog file as follows:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE message_catalog PUBLIC "weblogic-message-catalog-dtd" "http://www.bea.com/servers/wls600/msgcat.dtd">
      <message_catalog
         l10n_package="examples"
         i18n_package="examples"
         subsystem="LoggableExample"
         version="1.0"
         baseid="999000"
         endid="999999"
         loggables="true"
         >
         <logmessage
            messageid="999000"
            severity="info"
            method="logExample(String arg1)"
            >
            <messagebody>
               Test message with arg, {0}
            </messagebody>
            <messagedetail>
            </messagedetail>
            <cause>
            </cause>
            <action>
            </action>
         </logmessage>
      </message_catalog>

The above catalog defines the logExample(String) method plus a logExampleLoggable(String) method. The latter is created due to the presence of the `loggables="true"` setting for the `message_catalog` element. The logExample(String) method logs the message and returns the id of the message. The logExampleLoggable(String) method does not log the message, and returns the appropriate Loggable object for the message. Loggable objects are convenient for loggin messages and using the same text in a Throwable. For example,

     import examples.LoggableExampleLogger;
     import weblogic.logging.Loggable;
     ...
     // some error detected
     Loggable l = LoggableExampleLogger.logExampleLoggable("whatever");
     l.log();  // this logs the message
     throw new Exception(l.getMessage()); // creates exception with same text as logged

Author:
  Copyright © 2004 BEA Systems, Inc. All Rights Reserved.

Constructor Summary
`Loggable(java.lang.String id, java.lang.Object[] args)` Creates object that can be logged to the server log.

Method Summary
`java.lang.String` | `getId()` get the message id
`java.lang.String` | `getMessage()` get the message in current locale with [subsytem:id] prefix
`java.lang.String` | `getMessage(java.util.Locale l)` get the message in specified locale with [subsytem:id] prefix
`java.lang.String` | `getMessageText()` get the message in current locale, no prefix
`java.lang.String` | `getMessageText(java.util.Locale l)` get the message in specified locale, no prefix
`java.lang.String` | `log()` Log the message

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Loggable

    public Loggable(java.lang.String id,
                    java.lang.Object[] args)

  Creates object that can be logged to the server log.

Method Detail

### log

    public java.lang.String log()

  Log the message

### getMessage

    public java.lang.String getMessage()

  get the message in current locale with [subsytem:id] prefix

### getMessage

    public java.lang.String getMessage(java.util.Locale l)

  get the message in specified locale with [subsytem:id] prefix

### getMessageText

    public java.lang.String getMessageText()

  get the message in current locale, no prefix

### getMessageText

    public java.lang.String getMessageText(java.util.Locale l)

  get the message in specified locale, no prefix

### getId

    public java.lang.String getId()

  get the message id

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://e-docs.bea.com/wls/docs81
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD