Skip to content

Commit 58ebb34

Browse files
committed
chore: 로그 설정
1 parent 2b63ad1 commit 58ebb34

File tree

9 files changed

+165
-10
lines changed

9 files changed

+165
-10
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ application-prod.yml
4444
.DS_Store
4545

4646
./src/main/resources/config
47+
48+
/logs

build.gradle

+13-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ checkstyle {
1515

1616
check.dependsOn editorconfigCheck
1717

18-
group = 'com.ptmate'
18+
group = 'com.TnT'
1919
version = '0.0.1-SNAPSHOT'
2020
jar.enabled = false
2121

@@ -24,6 +24,10 @@ java {
2424
}
2525

2626
configurations {
27+
all {
28+
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
29+
}
30+
2731
compileOnly {
2832
extendsFrom annotationProcessor
2933
}
@@ -44,16 +48,21 @@ dependencies {
4448
implementation 'org.springframework.boot:spring-boot-starter-webflux'
4549

4650
// 애플 로그인을 위한 라이브러리
47-
implementation 'com.auth0:jwks-rsa:0.21.1'
51+
implementation 'com.auth0:jwks-rsa:0.22.1'
4852
implementation 'org.json:json:20231013'
49-
implementation 'org.bouncycastle:bcprov-jdk15on:1.70'
53+
implementation 'org.bouncycastle:bcprov-jdk18on:1.79'
5054

5155
// 레디스
5256
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
5357

58+
// Log4j2
59+
// -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector -> VM for Async Logger
60+
implementation 'org.springframework.boot:spring-boot-starter-log4j2'
61+
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.18.2'
62+
implementation 'com.lmax:disruptor:4.0.0'
63+
5464
annotationProcessor 'org.projectlombok:lombok'
5565

56-
developmentOnly 'org.springframework.boot:spring-boot-devtools'
5766
compileOnly 'org.projectlombok:lombok'
5867
runtimeOnly 'com.mysql:mysql-connector-j'
5968

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'PTMate'
1+
rootProject.name = 'TnT'

src/main/java/com/ptmate/PtMateApplication.java src/main/java/com/tnt/TnTApplication.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.ptmate;
1+
package com.tnt;
22

33
import java.util.TimeZone;
44

@@ -8,10 +8,10 @@
88
import jakarta.annotation.PostConstruct;
99

1010
@SpringBootApplication
11-
public class PtMateApplication {
11+
public class TnTApplication {
1212

1313
public static void main(String[] args) {
14-
SpringApplication.run(PtMateApplication.class, args);
14+
SpringApplication.run(TnTApplication.class, args);
1515
}
1616

1717
@PostConstruct

src/main/java/com/ptmate/global/config/SecurityConfig.java src/main/java/com/tnt/global/config/SecurityConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.ptmate.global.config;
1+
package com.tnt.global.config;
22

33
import org.springframework.context.annotation.Bean;
44
import org.springframework.context.annotation.Configuration;

src/main/resources/config

src/main/resources/log4j2-dev.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Configuration:
2+
name: Dev-Logger
3+
status: info
4+
5+
Properties:
6+
Property:
7+
- name: LOG_PATTERN_FILE
8+
value: "%d{yyyy-MM-dd HH:mm:ss} [%p] [%c{1.1.1.*}] %m%n"
9+
10+
- name: log-dir
11+
value: "logs"
12+
13+
Appenders:
14+
RollingFile:
15+
name: RollingFile_Appender
16+
fileName: "${log-dir}/logfile-${date:yyyy-MM-dd}.log"
17+
filePattern: "${log-dir}/logfile-%d{yyyy-MM-dd}.%i.txt"
18+
PatternLayout:
19+
pattern: "${LOG_PATTERN_FILE}"
20+
21+
Policies:
22+
SizeBasedTriggeringPolicy:
23+
size: "10 MB"
24+
TimeBasedTriggeringPolicy:
25+
Interval: 1
26+
modulate: true
27+
28+
DefaultRollOverStrategy:
29+
max: 10
30+
Delete:
31+
basePath: "${log-dir}"
32+
maxDepth: "1"
33+
IfLastModified:
34+
age: "P7D"
35+
36+
Loggers:
37+
Root:
38+
level: INFO
39+
AppenderRef:
40+
ref: RollingFile_Appender
41+
Logger:
42+
name: com.tnt
43+
additivity: false
44+
level: DEBUG
45+
includeLocation: false
46+
AppenderRef:
47+
ref: RollingFile_Appender

src/main/resources/log4j2-local.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Configuration:
2+
name: Local-Logger
3+
status: info
4+
5+
Properties:
6+
Property:
7+
- name: LOG_LEVEL_PATTERN
8+
value: "{FATAL=red blink, ERROR=red bold, WARN=yellow bold, INFO=green bold, DEBUG=blue bold, TRACE=blue}"
9+
10+
- name: LOG_PATTERN_SYS
11+
value: "%style{%d{yyyy-MM-dd HH:mm:ss}}{magenta} [%highlight{%p}${LOG_LEVEL_PATTERN}] %style{[%c{1.1.1.*}]}{cyan} %m%n"
12+
13+
Appenders:
14+
Console:
15+
name: Console_Appender
16+
target: SYSTEM_OUT
17+
PatternLayout:
18+
pattern: "${LOG_PATTERN_SYS}"
19+
20+
Loggers:
21+
Root:
22+
level: INFO
23+
AppenderRef:
24+
ref: Console_Appender
25+
Logger:
26+
name: com.tnt
27+
additivity: false
28+
level: DEBUG
29+
AppenderRef:
30+
ref: Console_Appender

src/main/resources/log4j2-prod.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
Configuration:
2+
name: Prod-Logger
3+
status: info
4+
5+
Properties:
6+
Property:
7+
- name: LOG_PATTERN_FILE
8+
value: "%d{yyyy-MM-dd HH:mm:ss} [%p] [%c{1.1.1.*}] %m%n"
9+
10+
- name: log-dir
11+
value: "logs"
12+
13+
Appenders:
14+
RollingFile:
15+
- name: RollingFile_Appender
16+
fileName: "${log-dir}/logfile-${date:yyyy-MM-dd}.log"
17+
filePattern: "${log-dir}/logfile-%d{yyyy-MM-dd}.%i.txt"
18+
PatternLayout:
19+
pattern: "${LOG_PATTERN_FILE}"
20+
21+
Policies:
22+
SizeBasedTriggeringPolicy:
23+
size: "10 MB"
24+
TimeBasedTriggeringPolicy:
25+
Interval: 1
26+
modulate: true
27+
28+
DefaultRollOverStrategy:
29+
max: 30
30+
Delete:
31+
basePath: "${log-dir}"
32+
maxDepth: "1"
33+
IfLastModified:
34+
age: "P7D"
35+
36+
- name: RollingFile_ERROR_Appender
37+
Filters:
38+
ThresholdFilter:
39+
level: ERROR
40+
onMatch: ACCEPT
41+
onMismatch: DENY
42+
fileName: "${log-dir}/ERROR-logfile-${date:yyyy-MM-dd}.log"
43+
filePattern: "${log-dir}/ERROR-logfile-%d{yyyy-MM-dd}.%i.txt"
44+
PatternLayout:
45+
pattern: "${LOG_PATTERN_FILE}"
46+
47+
Policies:
48+
SizeBasedTriggeringPolicy:
49+
size: "10 MB"
50+
TimeBasedTriggeringPolicy:
51+
Interval: 1
52+
modulate: true
53+
54+
DefaultRollOverStrategy:
55+
max: 30
56+
Delete:
57+
basePath: "${log-dir}"
58+
maxDepth: "1"
59+
IfLastModified:
60+
age: "P7D"
61+
62+
Loggers:
63+
Root:
64+
level: INFO
65+
AppenderRef:
66+
- ref: RollingFile_Appender
67+
- ref: RollingFile_ERROR_Appender

0 commit comments

Comments
 (0)