A Handler takes LogRecord objects from a Logger and, if their severity level is high enough, formats and publishes them to some destination (a file or socket, for example). The subclasses of this abstract class support various destinations, and implement destination-specific publish( ) , flush( ) and close( ) methods . In addition to the destination-specific abstract methods, this class also defines concrete methods used by most Handler subclasses. These are property getter and setter methods to specify the severity Level of logging messages to be handled, an optional Filter , a Formatter to convert log messages from LogRecord objects to text, a text encoding for the output text, and an ErrorManager to handle any exceptions that arise during log output. Subclass-specific defaults for each of these properties are typically defined as properties of LogManager and are read from a system-wide logging configuration file. In the simplest uses of the Logging API, a Logger sends it log messages to one or more handlers defined by the LogManager class for its "root logger". In this case there is no need for the application to ever instantiate or use a Handler directly. Applications that want custom control over the destination of their logs create and configure an instance of a Handler subclass, but never need to call its publish( ) , flush( ) or close( ) methods directly: that is done by the Logger . public abstract class Handler { // Protected Constructors protected Handler ( ); // Public Instance Methods public abstract void close ( ) throws SecurityException; public abstract void flush ( ); public String getEncoding ( ); public ErrorManager getErrorManager ( ); public Filter getFilter ( ); public java.util.logging.Formatter getFormatter ( ); public Level getLevel ( ); synchronized public boolean isLoggable (LogRecord record ); public abstract void publish (LogRecord record ); public void setEncoding (String encoding ) throws SecurityException, java.io.UnsupportedEncodingException; public void setErrorManager (ErrorManager em ); public void setFilter (Filter newFilter ) throws SecurityException; public void setFormatter (java.util.logging.Formatter newFormatter ) throws SecurityException; public void setLevel (Level newLevel ) throws SecurityException; synchronized // Protected Instance Methods protected void reportError (String msg , Exception ex , int code ); } SubclassesMemoryHandler , StreamHandler Passed Tojava.util.logging.Formatter.{getHead( ) , getTail( )} , Logger.{addHandler( ) , removeHandler( )} , MemoryHandler.MemoryHandler( ) , XMLFormatter.{getHead( ) , getTail( )} Returned ByLogger.getHandlers( ) |