Package wt.wvs
Class WVSLogger
java.lang.Object
wt.wvs.WVSLogger
A wrapper class (encapsulating the Log4j Logger) to help facilitate in acquiring
a logger for a specific WVS class adhering to a grouping structure. Instead of
using the full class name as the logger name, WVS will use this class to retrieve
a logger. This will allow a System Administrator to enable logging for a WVS
group. For example, if we have the following classes that are both used to
support publishing:
The WVSLogger class also contains additional supporting APIs to assist in performing logging functions. The following example illustrates how to use this class to acquire a logger and demonstrates some of the API's used to assist in logging.
Supported API: true
Extendable: false
com.ptc.wvs.server.publish.MyNewClass com.ptc.wvs.common.ui.AnotherNewClassAnd these classes retrieve a logger by doing the following:
private static final WVSLogger logger =
WVSLogger.getLogger(MyNewClass.class, WVSLogger.PUBLISH_GROUP);
private static final WVSLogger logger =
WVSLogger.getLogger(AnotherNewClass.class, WVSLogger.PUBLISH_GROUP);
The actual logger names for these classes will be "wt.wvs.publish.MyNewClass" and
"wt.wvs.publish.AnotherNewClass". Both our new classes belong to the publish group.
If a System Administrator enables logging for the "wt.wvs.pulish" group, logging
contained in both classes will be displayed despite that both classes actually reside
in different packages.
The WVSLogger class also contains additional supporting APIs to assist in performing logging functions. The following example illustrates how to use this class to acquire a logger and demonstrates some of the API's used to assist in logging.
class MyNewClass {
private static final WVSLogger logger =
WVSLogger.getLogger(MyNewClass.class, WVSLogger.PUBLISH_GROUP);
public String performPublishStuff(ConfigSpec configSpec, String template, WTPart part) {
boolean traceEnabled = logger.isTraceEnabled();
if (traceEnabled)
WVSLogger.traceMethodEntryVars("configSpec,template,part",
new Object[]{configSpec, template, part});
try {
logger.debug("starting to perform publish stuff");
// do some work.
String myReturnVal = "some stuff";
}
catch (Exception e) {
logger.error("An exception occurred when performing publish stuff", e);
}
if (traceEnabled)
WVSLogger.traceMethodExitVars("myReturnVal"
new Object[]{myReturnVal});
return myReturnVal;
}
}
Supported API: true
Extendable: false
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Supported API: truevoid
Supported API: truestatic WVSLoggerRetrieve WVSLogger for the given Class.static WVSLoggerRetrieve a WVSLogger with the name of the Class and the group as the prefix.static WVSLoggerRetrieve a WVSLogger with the logger's full name.static WVSLoggerRetrieve a WVSLogger with the short name of the logger and the group as the prefix.boolean
Supported API: true
-
Method Details
-
getLogger
Retrieve a WVSLogger with the logger's full name.- Parameters:
_loggerName- - logger full name.- Returns:
- WVSLogger - The WVSLogger of the specified name.
Supported API: true
-
getLogger
Retrieve a WVSLogger with the short name of the logger and the group as the prefix.- Parameters:
_shortName- - logger's short name._group- - Group prefix- Returns:
- WVSLogger - The WVSLogger of the specified group and short name.
Supported API: true
-
getLogger
Retrieve a WVSLogger with the name of the Class and the group as the prefix.- Parameters:
logClass- Class - target class in need of a logger.group- String - Group prefix- Returns:
- WVSLogger - WVSLogger for the target Class.
Supported API: true
-
getLogger
Retrieve WVSLogger for the given Class. We will use this if a particular class doesn't fall into the available groups.- Parameters:
logClass- Class - target class in need of a logger.- Returns:
- WVSLogger - WVSLogger for the target Class.
Supported API: true
-
debug
Supported API: true -
error
Supported API: true -
isDebugEnabled
public boolean isDebugEnabled()
Supported API: true
-