일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- tomcat
- bash
- xargs
- resource
- GIT
- 네트워크
- Windows
- profile
- VirtualBox
- plugin
- lsof
- Mac
- find
- Quartz
- import
- netsh
- 줄바꿈 문자
- grep
- 단축키
- Windows 10
- IntelliJ
- JavaScript
- ssh
- Source
- vscode
- port
- web.xml
- maVen
- Eclipse
- context
- Today
- Total
develog
[Java] log4j, add appender in source code 본문
PatternLayout patternLayout = new PatternLayout("[%d{yyyy-MM-dd HH:mm:ss}] [%-5p] %m%n");
ConsoleAppender consoleAppender = new ConsoleAppender(patternLayout);
RollingFileAppender rollFileAppender = new RollingFileAppender(patternLayout, "log/rolling.log");
rollFileAppender.setAppend(true);
rollFileAppender.setMaxFileSize("2MB");
rollFileAppender.setMaxBackupIndex(10);
DailyRollingFileAppender dailyRollingFileAppender = new DailyRollingFileAppender(patternLayout, "log/dailyRolling.log", ".yyyy-MM-dd");
dailyRollingFileAppender.setAppend(true);
Logger logger = Logger.getLogger(getClass());
logger.addAppender(consoleAppender);
logger.addAppender(rollFileAppender);
logger.addAppender(dailyRollingFileAppender);
logger.setAdditivity(false);
logger.setLevel(Level.ALL);
for (int i = 0; i < 1000000; i++) {
logger.debug(i + ". " + "TEST");
}
'Dev > Java' 카테고리의 다른 글
exception handling (0) | 2013.05.29 |
---|---|
logger.error (0) | 2013.05.29 |
정규표현식 #1 (0) | 2013.05.26 |
[java] html tag 제거 (0) | 2013.05.26 |
Collection List<Map> sort (0) | 2013.05.16 |