블로그 이미지

calendar

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
  • total
  • today
  • yesterday
2010. 1. 28. 10:33 JAVA언어

Log4J는 다음의 LEVEL을 갖는다.
Log4J의 LEVEL을 설정할때 아래의 순위에 따라 노출 범위가 결정된다.

ALL > TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF
오른쪽으로 갈수록 로그 출력이 위험 수위가 높은것만 출력 된다고 볼 수 있다.

Logger Output Hierarchy
원문링크 : http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/log4j.html

OFF

The OFF has the highest possible rank and is intended to turn off logging.
로깅 해제.

ALL
The ALL has the lowest possible rank and is intended to turn on all logging.
모든 로깅.

TRACE
The TRACE Level designates finer-grained informational events than the DEBUG
세밀

DEBUG
The DEBUG Level designates fine-grained informational events that are most useful to debug an application.
디버깅.

INFO
The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.
강조 정보.

WARN
The WARN level designates potentially harmful situations.
경고.

ERROR
The ERROR level designates error events that might still allow the application to continue running.
오류.

FATAL
The FATAL level designates very severe error events that will presumably lead the application to abort.
심각한 오류.
properties 설정
log4j.properties를 만들어 /WEB-INF/classes 밑에 놓으세요
파일명 : log4j.properties



VIII. 설정 포맷


로그파일명 포맷 (DatePattern)
로그파일명 포맷입니다. 날짜, 시간 및 분단위로까지 로그 파일을 분리할 수 있습니다.

형식 설명
'.'yyyy-MM 매달 첫번째날에 로그파일을 변경합니다
'.'yyyy-ww 매주의 시작시 로그파일을 변경합니다.
'.'yyyy-MM-dd 매일 자정에 로그파일을 변경합니다.
'.'yyyy-MM-dd-a 자정과 정오에 로그파일을 변경합니다.
'.'yyyy-MM-dd-HH 매 시간의 시작마다 로그파일을 변경합니다.
'.'yyyy-MM-dd-HH-mm 매분마다 로그파일을 변경합니다.



PatternLayout 포맷
로그자체를 어떤 포맷으로 남길지 결정합니다.
layout에는 HTMLLayout, PatternLayout, SimpleLayout, XMLLayout등이 있으며 PatternLayout이 일반적으로 가장 많이 쓰입니다.


형식 설명
%p debug, info, warn, error, fatal 등의 priority 가 출력된다.
%m 로그내용이 출력됩니다
%d 로깅 이벤트가 발생한 시간을 기록합니다.
포맷은 %d{HH:mm:ss, SSS}, %d{yyyy MMM dd HH:mm:ss, SSS}같은 형태로 사용하며 SimpleDateFormat에 따른 포맷팅을 하면 된다
%t 로그이벤트가 발생된 쓰레드의 이름을 출력합니다.
%% % 표시를 출력하기 위해 사용한다.
%n 플랫폼 종속적인 개행문자가 출력된다. \r\n 또는 \n 일것이다.
%c 카테고리를 표시합니다
예) 카테고리가 a.b.c 처럼 되어있다면 %c{2}는 b.c가 출력됩니다.
%C 클래스명을 포시합니다.
예) 클래스구조가 org.apache.xyz.SomeClass 처럼 되어있다면 %C{2}는 xyz.SomeClass 가 출력됩니다
%F 로깅이 발생한 프로그램 파일명을 나타냅니다.
%l 로깅이 발생한 caller의 정보를 나타냅니다
%L 로깅이 발생한 caller의 라인수를 나타냅니다
%M 로깅이 발생한 method 이름을 나타냅니다.
%r 어플리케이션 시작 이후 부터 로깅이 발생한 시점의 시간(milliseconds)
%x 로깅이 발생한 thread와 관련된 NDC(nested diagnostic context)를 출력합니다.
%X 로깅이 발생한 thread와 관련된 MDC(mapped diagnostic context)를 출력합니다.

예시) (같은 색끼리 보시면 됩니다)

위의 test.jsp를 다음 포맷으로 출력해본다면

[%c] [%C] [%d] [%F] [%l] [%L] [%m] [%M] [%n] [%p] [%r] [%t] [%x] [%X]는 다음과 같다

[test.jsp] [org.apache.jsp.test_jsp] [2005-03-10 12:37:23,561] [test_jsp.java] [org.apache.jsp.test_jsp._jspService(test_jsp.java:64)] [64] [fatal!!] [_jspService] [개행] [FATAL] [765567] [http-8080-Processor25] [] []


'JAVA언어' 카테고리의 다른 글

Java 자료형과 동기화 방법.  (0) 2010.05.11
한글깨짐 get,post 참조  (0) 2010.03.31
달력 만들기  (0) 2010.03.09
페이지 요청에서부터 쿠키셋팅 POST 보내기  (0) 2010.03.05
SWT DnD 파일,텍스트 예제  (0) 2010.02.08
posted by 천상의날개