Loggablepublic class Loggable
extends java.lang.Object
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 logging 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
| Modifier and Type | Method | Description |
|---|---|---|
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 |
getMessageBody() |
Gets the contents of the message body without appending a stack trace.
|
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.
|
static boolean |
isAppendStackTraceEnabled() |
|
java.lang.String |
log() |
Log the message.
|
public java.lang.String log()
public java.lang.String getMessageBody()
public static boolean isAppendStackTraceEnabled()
public java.lang.String getMessage()
public java.lang.String getMessage(java.util.Locale l)
public java.lang.String getMessageText()
public java.lang.String getMessageText(java.util.Locale l)
public java.lang.String getId()