2010년 5월 28일 금요일

JDK logger 초기화

LogManager logMgr = LogManager.getLogManager();
URL configURL = getClass().getResource("/config/JDKLog.properties");
InputStream ins;
           try {
               ins = configURL.openStream();
               if( ins != null )
                   logMgr.readConfiguration(ins);
               else
                   logger.log( Level.WARNING, "Failed to open JDKLog.properties");
           } catch (IOException e) {
               // TODO 자동 생성된 catch 블록
               e.printStackTrace();
           }

---------------------JDKLog.properties-------------------
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=ALL
.level=FINEST

댓글 1개:

  1. java login API included since JDK1.4. It is very flexable toolkit. You can use own handler, filter and formtter.
    How to config logger.
    You can use properties file to config your logger. Default file is JAVA_HOME/lib/logging.properties. If you want to use another property file, you can specify file path with -D JVM option.

    답글삭제