package com.asiana.pip;
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class LoggerTest1 {
private Logger logger;
public LoggerTest1() {
super();
/**
* Logger setting
*/
this.logger = Logger.getLogger("com.asiana.pip.LoggerTest1");
FileHandler handler = null;
try {
handler = new FileHandler("./log/LoggerTest1.%g.log", 1024*1024*10, 10);
} catch (IOException e) {
e.printStackTrace();
}
handler.setFormatter(new SimpleFormatter());
this.logger.addHandler(handler);
this.logger.setLevel(Level.CONFIG);
}
public void logging() {
this.logger.log(Level.INFO, "LoggerTest1 Log.");
}
}
하위 class
package com.asiana.pip.log;
import com.asiana.pip.LoggerTest1;
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class LoggerTestChild {
private Logger logger;
public LoggerTestChild() {
super();
/**
* Logger setting
*/
this.logger = Logger.getLogger("com.asiana.pip.LoggerTest1.LoggerTestChild");
}
public void logging() {
this.logger.log(Level.INFO, "LoggerTest1 Log.");
}
public static void main(String args[]) {
LoggerTest1 test1= new LoggerTest1();
LoggerTestChild child = new LoggerTestChild();
test1.logging();
child.logging();
child.logging();
test1.logging();
}
}
결과 log 파일(LoggerTest1.0.log)
2014. 4. 10 오전 8:42:11 com.asiana.pip.LoggerTest1 logging
정보: LoggerTest1 Log.
2014. 4. 10 오전 8:42:12 com.asiana.pip.log.LoggerTestChild logging
정보: LoggerTest1 Log.
2014. 4. 10 오전 8:42:12 com.asiana.pip.log.LoggerTestChild logging
정보: LoggerTest1 Log.
2014. 4. 10 오전 8:42:12 com.asiana.pip.LoggerTest1 logging
정보: LoggerTest1 Log.
java process 옵션 검색 명령 jps (0) | 2014.04.18 |
---|---|
html chart 는 google chart 가 좋네요 (0) | 2014.04.16 |
java simple logging (0) | 2014.01.23 |
JDBC 엑사데이터 RAC 접속 string (0) | 2013.11.29 |
gmail을 이용한 java mail sender 프로그램 (0) | 2013.11.11 |
댓글 영역