1 7 8 9 package java.util.logging; 10 11 import java.io.*; 12 import java.net.*; 13 14 40 41 public class ConsoleHandler extends StreamHandler { 42 private void configure() { 46 LogManager manager = LogManager.getLogManager(); 47 String cname = getClass().getName(); 48 49 setLevel(manager.getLevelProperty(cname +".level", Level.INFO)); 50 setFilter(manager.getFilterProperty(cname +".filter", null)); 51 setFormatter(manager.getFormatterProperty(cname +".formatter", new SimpleFormatter ())); 52 try { 53 setEncoding(manager.getStringProperty(cname +".encoding", null)); 54 } catch (Exception ex) { 55 try { 56 setEncoding(null); 57 } catch (Exception ex2) { 58 } 61 } 62 } 63 64 71 public ConsoleHandler() { 72 sealed = false; 73 configure(); 74 setOutputStream(System.err); 75 sealed = true; 76 } 77 78 87 public void publish(LogRecord record) { 88 super.publish(record); 89 flush(); 90 } 91 92 97 public void close() { 98 flush(); 99 } 100 } 101 102 | Popular Tags |