Save This Page
Home » openjdk-7 » java » util » logging » [javadoc | source]
java.util.logging
abstract public class: Handler [javadoc | source]
java.lang.Object
   java.util.logging.Handler

Direct Known Subclasses:
    ConsoleHandler, FileHandler, StreamHandler, SocketHandler, MemoryHandler

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.

Handler classes typically use LogManager properties to set default values for the Handler's Filter, Formatter, and Level. See the specific documentation for each concrete Handler class.

Field Summary
 boolean sealed     
Constructor:
 protected Handler() 
Method from java.util.logging.Handler Summary:
checkAccess,   close,   flush,   getEncoding,   getErrorManager,   getFilter,   getFormatter,   getLevel,   isLoggable,   publish,   reportError,   setEncoding,   setErrorManager,   setFilter,   setFormatter,   setLevel
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.util.logging.Handler Detail:
  void checkAccess() throws SecurityException 
 abstract public  void close() throws SecurityException
    Close the Handler and free all associated resources.

    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.

 abstract public  void flush()
    Flush any buffered output.
 public String getEncoding() 
    Return the character encoding for this Handler.
 public ErrorManager getErrorManager() 
    Retrieves the ErrorManager for this Handler.
 public Filter getFilter() 
    Get the current Filter for this Handler.
 public Formatter getFormatter() 
    Return the Formatter for this Handler.
 public synchronized Level getLevel() 
    Get the log level specifying which messages will be logged by this Handler. Message levels lower than this level will be discarded.
 public boolean isLoggable(LogRecord record) 
    Check if this Handler would actually log a given LogRecord.

    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.

 abstract public  void publish(LogRecord record)
    Publish a LogRecord.

    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.

 protected  void reportError(String msg,
    Exception ex,
    int code) 
    Protected convenience method to report an error to this Handler's ErrorManager. Note that this method retrieves and uses the ErrorManager without doing a security check. It can therefore be used in environments where the caller may be non-privileged.
 public  void setEncoding(String encoding) throws SecurityException, UnsupportedEncodingException 
    Set the character encoding used by this Handler.

    The encoding should be set before any LogRecords are written to the Handler.

 public  void setErrorManager(ErrorManager em) 
    Define an ErrorManager for this Handler.

    The ErrorManager's "error" method will be invoked if any errors occur while using this Handler.

 public  void setFilter(Filter newFilter) throws SecurityException 
    Set a Filter to control output on this Handler.

    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.

 public  void setFormatter(Formatter newFormatter) throws SecurityException 
    Set a Formatter. This Formatter will be used to format LogRecords for this Handler.

    Some Handlers may not use Formatters, in which case the Formatter will be remembered, but not used.

 public synchronized  void setLevel(Level newLevel) throws SecurityException 
    Set the log level specifying which message levels will be logged by this Handler. Message levels lower than this value will be discarded.

    The intention is to allow developers to turn on voluminous logging, but to limit the messages that are sent to certain Handlers.