|
Oracle Java ME Embedded | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.oracle.util.logging.Handler
public abstract class Handler
A Handler object takes log messages from a Logger and exports them. It might for example, write them to a console or write them to a file, or send them to a network logging service, or forward them to an OS log, or whatever.
A Handler can be disabled by doing a setLevel(Level.OFF) and can be re-enabled by doing a setLevel with an appropriate level.
Constructor Summary | |
protected |
Handler()
Default constructor. |
Method Summary | |
abstract void |
close()
Close the Handler and free all associated resources. |
abstract void |
flush()
Flush any buffered output. |
Filter |
getFilter()
Get the current Filter for this Handler. |
Formatter |
getFormatter()
Return the Formatter for this Handler. |
Level |
getLevel()
Get the log level specifying which messages will be logged by this Handler. |
boolean |
isLoggable(LogRecord record)
Check if this Handler would actually log a given LogRecord. |
abstract void |
publish(LogRecord record)
Publish a LogRecord. |
protected void |
reportError(java.lang.String msg,
java.lang.Exception ex,
int code)
Protected convenience method to report an error. |
void |
setFilter(Filter newFilter)
Set a Filter to control output on this Handler. |
void |
setFormatter(Formatter newFormatter)
Set a Formatter. |
void |
setLevel(Level newLevel)
Set the log level specifying which message levels will be logged by this Handler. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected Handler()
Method Detail |
public abstract void publish(LogRecord record)
The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here.
The Handler is responsible for formatting the message, when and if necessary. The formatting should include localization.
record
- description of the log event. A null record is
silently ignored and is not publishedpublic abstract void flush()
public abstract void close() throws java.lang.SecurityException
The close method will perform a flush and then close the Handler. After close has been called this Handler should no longer be used. Method calls may either be silently ignored or may throw runtime exceptions.
java.lang.SecurityException
- if a security manager exists and if
the caller does not have LoggingPermission("control").public void setFormatter(Formatter newFormatter) throws java.lang.SecurityException
Some Handlers may not use Formatters, in which case the Formatter will be remembered, but not used.
newFormatter
- the Formatter to use (may not be null)
java.lang.SecurityException
- if a security manager exists and if
the caller does not have LoggingPermission("control").public Formatter getFormatter()
public void setFilter(Filter newFilter) throws java.lang.SecurityException
For each call of publish the Handler will call this Filter (if it is non-null) to check if the LogRecord should be published or discarded.
newFilter
- a Filter object (may be null)
java.lang.SecurityException
- if a security manager exists and if
the caller does not have LoggingPermission("control").public Filter getFilter()
protected void reportError(java.lang.String msg, java.lang.Exception ex, int code)
msg
- a descriptive string (may be null)ex
- an exception (may be null)code
- an error codepublic void setLevel(Level newLevel) throws java.lang.SecurityException
The intention is to allow developers to turn on voluminous logging, but to limit the messages that are sent to certain Handlers.
newLevel
- the new value for the log level
java.lang.SecurityException
- if a security manager exists and if
the caller does not have LoggingPermission("control").public Level getLevel()
public boolean isLoggable(LogRecord record)
This method checks if the LogRecord has an appropriate Level and whether it satisfies any Filter. It also may make other Handler specific checks that might prevent a handler from logging the LogRecord. It will return false if the LogRecord is null.
record
- a LogRecord
|
Oracle Java ME Embedded | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |