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

Print this page




  79         try {
  80             setEncoding(manager.getStringProperty(cname +".encoding", null));
  81         } catch (Exception ex) {
  82             try {
  83                 setEncoding(null);
  84             } catch (Exception ex2) {
  85                 // doing a setEncoding with null should always work.
  86                 // assert false;
  87             }
  88         }
  89     }
  90 
  91     /**
  92      * Create a <tt>ConsoleHandler</tt> for <tt>System.err</tt>.
  93      * <p>
  94      * The <tt>ConsoleHandler</tt> is configured based on
  95      * <tt>LogManager</tt> properties (or their default values).
  96      *
  97      */
  98     public ConsoleHandler() {
  99         sealed = false;
 100         configure();
 101         setOutputStream(System.err);
 102         sealed = true;
 103     }
 104 
 105     /**
 106      * Publish a <tt>LogRecord</tt>.
 107      * <p>
 108      * The logging request was made initially to a <tt>Logger</tt> object,
 109      * which initialized the <tt>LogRecord</tt> and forwarded it here.
 110      * <p>
 111      * @param  record  description of the log event. A null record is
 112      *                 silently ignored and is not published
 113      */
 114     @Override
 115     public void publish(LogRecord record) {
 116         super.publish(record);
 117         flush();
 118     }
 119 
 120     /**
 121      * Override <tt>StreamHandler.close</tt> to do a flush but not
 122      * to close the output stream.  That is, we do <b>not</b>


  79         try {
  80             setEncoding(manager.getStringProperty(cname +".encoding", null));
  81         } catch (Exception ex) {
  82             try {
  83                 setEncoding(null);
  84             } catch (Exception ex2) {
  85                 // doing a setEncoding with null should always work.
  86                 // assert false;
  87             }
  88         }
  89     }
  90 
  91     /**
  92      * Create a <tt>ConsoleHandler</tt> for <tt>System.err</tt>.
  93      * <p>
  94      * The <tt>ConsoleHandler</tt> is configured based on
  95      * <tt>LogManager</tt> properties (or their default values).
  96      *
  97      */
  98     public ConsoleHandler() {
  99         doWithControlPermission(() -> {
 100             configure();
 101             setOutputStream(System.err);
 102         });
 103     }
 104 
 105     /**
 106      * Publish a <tt>LogRecord</tt>.
 107      * <p>
 108      * The logging request was made initially to a <tt>Logger</tt> object,
 109      * which initialized the <tt>LogRecord</tt> and forwarded it here.
 110      * <p>
 111      * @param  record  description of the log event. A null record is
 112      *                 silently ignored and is not published
 113      */
 114     @Override
 115     public void publish(LogRecord record) {
 116         super.publish(record);
 117         flush();
 118     }
 119 
 120     /**
 121      * Override <tt>StreamHandler.close</tt> to do a flush but not
 122      * to close the output stream.  That is, we do <b>not</b>