Methods Summary |
---|
public java.util.logging.Level | getLevel()Get the logging message level, for example Level.SEVERE.
return level;
|
public java.lang.String | getLoggerName()Get the source Logger name's
return loggerName;
|
public java.lang.String | getMessage()Get the "raw" log message, before localization or formatting.
May be null, which is equivalent to the empty string "".
This message may be either the final text or a localization key.
During formatting, if the source logger has a localization
ResourceBundle and if that ResourceBundle has an entry for
this message string, then the message string is replaced
with the localized value.
return message;
|
public long | getMillis()Get event time in milliseconds since 1970.
return millis;
|
public java.lang.Object[] | getParameters()Get the parameters to the log message.
return parameters;
|
public java.util.ResourceBundle | getResourceBundle()Get the localization resource bundle
This is the ResourceBundle that should be used to localize
the message string before formatting it. The result may
be null if the message is not localizable, or if no suitable
ResourceBundle is available.
return resourceBundle;
|
public java.lang.String | getResourceBundleName()Get the localization resource bundle name
This is the name for the ResourceBundle that should be
used to localize the message string before formatting it.
The result may be null if the message is not localizable.
return resourceBundleName;
|
public long | getSequenceNumber()Get the sequence number.
Sequence numbers are normally assigned in the LogRecord
constructor, which assigns unique sequence numbers to
each new LogRecord in increasing order.
return sequenceNumber;
|
public java.lang.String | getSourceClassName()Get the name of the class that (allegedly) issued the logging request.
Note that this sourceClassName is not verified and may be spoofed.
This information may either have been provided as part of the
logging call, or it may have been inferred automatically by the
logging framework. In the latter case, the information may only
be approximate and may in fact describe an earlier call on the
stack frame.
May be null if no information could be obtained.
if (needToInferCaller) {
inferCaller();
}
return sourceClassName;
|
public java.lang.String | getSourceMethodName()Get the name of the method that (allegedly) issued the logging request.
Note that this sourceMethodName is not verified and may be spoofed.
This information may either have been provided as part of the
logging call, or it may have been inferred automatically by the
logging framework. In the latter case, the information may only
be approximate and may in fact describe an earlier call on the
stack frame.
May be null if no information could be obtained.
if (needToInferCaller) {
inferCaller();
}
return sourceMethodName;
|
public int | getThreadID()Get an identifier for the thread where the message originated.
This is a thread identifier within the Java VM and may or
may not map to any operating system ID.
return threadID;
|
public java.lang.Throwable | getThrown()Get any throwable associated with the log record.
If the event involved an exception, this will be the
exception object. Otherwise null.
return thrown;
|
private void | inferCaller()
needToInferCaller = false;
// Get the stack trace.
StackTraceElement stack[] = (new Throwable()).getStackTrace();
// First, search back to a method in the Logger class.
int ix = 0;
while (ix < stack.length) {
StackTraceElement frame = stack[ix];
String cname = frame.getClassName();
if (cname.equals("java.util.logging.Logger")) {
break;
}
ix++;
}
// Now search for the first frame before the "Logger" class.
while (ix < stack.length) {
StackTraceElement frame = stack[ix];
String cname = frame.getClassName();
if (!cname.equals("java.util.logging.Logger")) {
// We've found the relevant frame.
setSourceClassName(cname);
setSourceMethodName(frame.getMethodName());
return;
}
ix++;
}
// We haven't found a suitable frame, so just punt. This is
// OK as we are only committed to making a "best effort" here.
|
private void | readObject(java.io.ObjectInputStream in)
// We have to call defaultReadObject first.
in.defaultReadObject();
// Read version number.
byte major = in.readByte();
byte minor = in.readByte();
if (major != 1) {
throw new IOException("LogRecord: bad version: " + major + "." + minor);
}
int len = in.readInt();
if (len == -1) {
parameters = null;
} else {
parameters = new Object[len];
for (int i = 0; i < parameters.length; i++) {
parameters[i] = in.readObject();
}
}
// If necessary, try to regenerate the resource bundle.
if (resourceBundleName != null) {
try {
resourceBundle = ResourceBundle.getBundle(resourceBundleName);
} catch (MissingResourceException ex) {
// This is not a good place to throw an exception,
// so we simply leave the resourceBundle null.
resourceBundle = null;
}
}
needToInferCaller = false;
|
public void | setLevel(java.util.logging.Level level)Set the logging message level, for example Level.SEVERE.
if (level == null) {
throw new NullPointerException();
}
this.level = level;
|
public void | setLoggerName(java.lang.String name)Set the source Logger name.
loggerName = name;
|
public void | setMessage(java.lang.String message)Set the "raw" log message, before localization or formatting.
this.message = message;
|
public void | setMillis(long millis)Set event time.
this.millis = millis;
|
public void | setParameters(java.lang.Object[] parameters)Set the parameters to the log message.
this.parameters = parameters;
|
public void | setResourceBundle(java.util.ResourceBundle bundle)Set the localization resource bundle.
resourceBundle = bundle;
|
public void | setResourceBundleName(java.lang.String name)Set the localization resource bundle name.
resourceBundleName = name;
|
public void | setSequenceNumber(long seq)Set the sequence number.
Sequence numbers are normally assigned in the LogRecord constructor,
so it should not normally be necessary to use this method.
sequenceNumber = seq;
|
public void | setSourceClassName(java.lang.String sourceClassName)Set the name of the class that (allegedly) issued the logging request.
this.sourceClassName = sourceClassName;
needToInferCaller = false;
|
public void | setSourceMethodName(java.lang.String sourceMethodName)Set the name of the method that (allegedly) issued the logging request.
this.sourceMethodName = sourceMethodName;
needToInferCaller = false;
|
public void | setThreadID(int threadID)Set an identifier for the thread where the message originated.
this.threadID = threadID;
|
public void | setThrown(java.lang.Throwable thrown)Set a throwable associated with the log event.
this.thrown = thrown;
|
private void | writeObject(java.io.ObjectOutputStream out)
// We have to call defaultWriteObject first.
out.defaultWriteObject();
// Write our version number.
out.writeByte(1);
out.writeByte(0);
if (parameters == null) {
out.writeInt(-1);
return;
}
out.writeInt(parameters.length);
// Write string values for the parameters.
for (int i = 0; i < parameters.length; i++) {
if (parameters[i] == null) {
out.writeObject(null);
} else {
out.writeObject(parameters[i].toString());
}
}
|