일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Mac
- db
- ojdbc6
- oracle
- 코어자바스크립트
- Java
- kubernetes dns 질의
- TypeScript
- DART
- maven
- 봤어요처리
- Spring
- 프로그래머스
- svn
- @RequestBody
- Stream
- 프로젝트 여러 개
- InteliJ
- Aspect
- MySQL
- datagrip 한글깨짐
- javascript error
- SQL
- 인텔리제이
- node.js
- class-transformer
- tecoble
- REST
- JavaScript
- eqauls-hashcode
- Today
- Total
개발자가 되고 싶은 개발자
[Log4j2] Log4j2- PatternLayout 본문
목적
- Log4j2에서의 PatternLayout의 속성에 관하여 숙지
정의
- 패턴 문자열로 구성 가능한 유연한 레이아웃. (A flexible layout configurable with pattern string.)
사용법
- 각 변환 지정자는 (%) 기호로 시작하고, 뒤에 선택적 형식 지정자와 변환 문자가 옴
(Each conversion specifier starts with a percent sign (%) and is followed by optional format modifiers and a conversion character. )
속성(기본적으로 사용되는 속성만 기록함)
- p: 로깅이벤트의 우선순위를 출력하는데 사용됨 (Used to output the priority of the logging event.)
- d: 로깅이벤트의 날짜를 출력하는데 사용됨 (Used to output the date of the logging event.)
- c: 로깅이벤트의 카테고리를 출력하는데 사용됨 (Used to output the category of the logging event.)
- m: 로깅이벤트와 연관된 어플리케이션 제공 메시지를 출력하는데 사용됨
(Used to output the application supplied message associated with the logging event.)
- n: 개행문자를 출력함 (Outputs the platform dependent line separator character or characters.)
예시
// 형식지정자가 다음과 같이 지정되었다고 가정
%-5p [%t]: %m%n
Category root = Category.getRoot();
root.debug("Message 1");
root.warn("Message 2");
// 다음과 같은 결과를 도출할 것임
DEBUG [main]: Message 1
WARN [main]: Message 2
// log4j2.xml 예시
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d %5p [%c] %m%n" />
</Console>
</Appenders>
Log4j – Log4j 2 Layouts
facility String The facility is used to try to classify the message. The facility option must be set to one of "KERN", "USER", "MAIL", "DAEMON", "AUTH", "SYSLOG", "LPR", "NEWS", "UUCP", "CRON", "AUTHPRIV", "FTP", "NTP", "AUDIT", "ALERT", "CLOCK", "LOCAL0",
logging.apache.org
메모
- slfj > log4j> logback> log4j2 순으로 출시됨
'Dev > Java & Spring' 카테고리의 다른 글
[Spring] Spring Batch (0) | 2021.11.06 |
---|---|
[Java] Stream (0) | 2021.10.05 |
[Tomcat] 톰캣 서버 실행 시 리스너 오류 (0) | 2021.02.04 |
[Java] 클래스 변수/인스턴스 변수 · 클래스 메소드/인스턴스 메소드 (0) | 2021.01.12 |
[Java] NullPointerException Case1 (0) | 2020.09.07 |