src/share/classes/java/util/logging/Handler.java

Print this page




  28 
  29 import java.io.UnsupportedEncodingException;
  30 /**
  31  * A <tt>Handler</tt> object takes log messages from a <tt>Logger</tt> and
  32  * exports them.  It might for example, write them to a console
  33  * or write them to a file, or send them to a network logging service,
  34  * or forward them to an OS log, or whatever.
  35  * <p>
  36  * A <tt>Handler</tt> can be disabled by doing a <tt>setLevel(Level.OFF)</tt>
  37  * and can  be re-enabled by doing a <tt>setLevel</tt> with an appropriate level.
  38  * <p>
  39  * <tt>Handler</tt> classes typically use <tt>LogManager</tt> properties to set
  40  * default values for the <tt>Handler</tt>'s <tt>Filter</tt>, <tt>Formatter</tt>,
  41  * and <tt>Level</tt>.  See the specific documentation for each concrete
  42  * <tt>Handler</tt> class.
  43  *
  44  *
  45  * @since 1.4
  46  */
  47 
  48 public abstract class Handler {
  49     private static final int offValue = Level.OFF.intValue();
  50     private LogManager manager = LogManager.getLogManager();
  51     private Filter filter;
  52     private Formatter formatter;
  53     private Level logLevel = Level.ALL;
  54     private ErrorManager errorManager = new ErrorManager();
  55     private String encoding;
  56 
  57     // Package private support for security checking.  When sealed
  58     // is true, we access check updates to the class.
  59     boolean sealed = true;
  60 
  61     /**
  62      * Default constructor.  The resulting <tt>Handler</tt> has a log
  63      * level of <tt>Level.ALL</tt>, no <tt>Formatter</tt>, and no
  64      * <tt>Filter</tt>.  A default <tt>ErrorManager</tt> instance is installed
  65      * as the <tt>ErrorManager</tt>.
  66      */
  67     protected Handler() {
  68     }




  28 
  29 import java.io.UnsupportedEncodingException;
  30 /**
  31  * A <tt>Handler</tt> object takes log messages from a <tt>Logger</tt> and
  32  * exports them.  It might for example, write them to a console
  33  * or write them to a file, or send them to a network logging service,
  34  * or forward them to an OS log, or whatever.
  35  * <p>
  36  * A <tt>Handler</tt> can be disabled by doing a <tt>setLevel(Level.OFF)</tt>
  37  * and can  be re-enabled by doing a <tt>setLevel</tt> with an appropriate level.
  38  * <p>
  39  * <tt>Handler</tt> classes typically use <tt>LogManager</tt> properties to set
  40  * default values for the <tt>Handler</tt>'s <tt>Filter</tt>, <tt>Formatter</tt>,
  41  * and <tt>Level</tt>.  See the specific documentation for each concrete
  42  * <tt>Handler</tt> class.
  43  *
  44  *
  45  * @since 1.4
  46  */
  47 
  48 public abstract class Handler implements AutoCloseable {
  49     private static final int offValue = Level.OFF.intValue();
  50     private LogManager manager = LogManager.getLogManager();
  51     private Filter filter;
  52     private Formatter formatter;
  53     private Level logLevel = Level.ALL;
  54     private ErrorManager errorManager = new ErrorManager();
  55     private String encoding;
  56 
  57     // Package private support for security checking.  When sealed
  58     // is true, we access check updates to the class.
  59     boolean sealed = true;
  60 
  61     /**
  62      * Default constructor.  The resulting <tt>Handler</tt> has a log
  63      * level of <tt>Level.ALL</tt>, no <tt>Formatter</tt>, and no
  64      * <tt>Filter</tt>.  A default <tt>ErrorManager</tt> instance is installed
  65      * as the <tt>ErrorManager</tt>.
  66      */
  67     protected Handler() {
  68     }