| Method from org.apache.log4j.lf5.LogRecord Detail: |
public String getCategory() {
return (_category);
}
Get the category asscociated with this LogRecord. For a more detailed
description of what a category is see setCategory(). |
public LogLevel getLevel() {
return (_level);
}
Get the level of this LogRecord. |
public String getLocation() {
return _location;
}
Get the location in code where this LogRecord originated. |
public String getMessage() {
return (_message);
}
Get the message asscociated with this LogRecord. |
public long getMillis() {
return _millis;
}
Get the event time of this record in milliseconds from 1970.
When a LogRecord is constructed the event time is set but may be
overridden by calling setMillis(); |
public String getNDC() {
return _ndc;
}
Get the NDC (nested diagnostic context) for this record. |
protected static synchronized long getNextId() {
_seqCount++;
return _seqCount;
}
|
public long getSequenceNumber() {
return (_sequenceNumber);
}
Get the sequence number associated with this LogRecord. Sequence numbers
are generally assigned when a LogRecord is constructed. Sequence numbers
start at 0 and increase with each newly constructed LogRocord. |
public String getThreadDescription() {
return (_thread);
}
Get the thread description asscociated with this LogRecord. When a
LogRecord is constructed, the thread description is set by calling:
Thread.currentThread().toString(). You may supply a thread description
of your own by calling the setThreadDescription(String) method. |
public Throwable getThrown() {
return (_thrown);
}
Get the Throwable associated with this LogRecord. |
public String getThrownStackTrace() {
return (_thrownStackTrace);
}
Get the stack trace in a String-based format for the associated Throwable
of this LogRecord. The stack trace in a String-based format is set
when the setThrown(Throwable) method is called.
Why do we need this method considering that we
have the getThrown() and setThrown() methods?
A Throwable object may not be serializable, however, a String representation
of it is. Users of LogRecords should generally call this method over
getThrown() for the reasons of serialization.
|
public boolean hasThrown() {
Throwable thrown = getThrown();
if (thrown == null) {
return false;
}
String thrownString = thrown.toString();
return thrownString != null && thrownString.trim().length() != 0;
}
|
public boolean isFatal() {
return isSevereLevel() || hasThrown();
}
|
abstract public boolean isSevereLevel()
Abstract method. Must be overridden to indicate what log level
to show in red. |
public static synchronized void resetSequenceNumber() {
_seqCount = 0;
}
Resets that sequence number to 0. |
public void setCategory(String category) {
_category = category;
}
Set the category associated with this LogRecord. A category represents
a hierarchical dot (".") separated namespace for messages.
The definition of a category is application specific, but a common convention
is as follows:
When logging messages
for a particluar class you can use its class name:
com.thoughtworks.framework.servlet.ServletServiceBroker.
Futhermore, to log a message for a particular method in a class
add the method name:
com.thoughtworks.framework.servlet.ServletServiceBroker.init().
|
public void setLevel(LogLevel level) {
_level = level;
}
Set the level of this LogRecord. |
public void setLocation(String location) {
_location = location;
}
Set the location in code where this LogRecord originated. |
public void setMessage(String message) {
_message = message;
}
Set the message associated with this LogRecord. |
public void setMillis(long millis) {
_millis = millis;
}
Set the event time of this record. When a LogRecord is constructed
the event time is set but may be overridden by calling this method. |
public void setNDC(String ndc) {
_ndc = ndc;
}
Set the NDC (nested diagnostic context) for this record. |
public void setSequenceNumber(long number) {
_sequenceNumber = number;
}
Set the sequence number assocsiated with this LogRecord. A sequence number
will automatically be assigned to evey newly constructed LogRecord, however,
this method can override the value. |
public void setThreadDescription(String threadDescription) {
_thread = threadDescription;
}
Set the thread description associated with this LogRecord. When a
LogRecord is constructed, the thread description is set by calling:
Thread.currentThread().toString(). You may supply a thread description
of your own by calling this method. |
public void setThrown(Throwable thrown) {
if (thrown == null) {
return;
}
_thrown = thrown;
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
thrown.printStackTrace(out);
out.flush();
_thrownStackTrace = sw.toString();
try {
out.close();
sw.close();
} catch (IOException e) {
// Do nothing, this should not happen as it is StringWriter.
}
out = null;
sw = null;
}
Set the Throwable associated with this LogRecord. When this method
is called, the stack trace in a String-based format is made
available via the getThrownStackTrace() method. |
public void setThrownStackTrace(String trace) {
_thrownStackTrace = trace;
}
Set the ThrownStackTrace for the log record. |
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("LogRecord: [" + _level + ", " + _message + "]");
return (buf.toString());
}
Return a String representation of this LogRecord. |