Skip to content

Commit 9e21550

Browse files
committed
chore: slack과 error log 연동
1 parent 9bbea05 commit 9e21550

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dependencies {
3939
implementation 'com.amazonaws:aws-java-sdk-s3:1.12.122'
4040
implementation 'ch.qos.logback:logback-classic:1.2.8'
4141
implementation 'ch.qos.logback:logback-core:1.2.8'
42+
implementation 'com.github.maricn:logback-slack-appender:1.4.0'
4243
compileOnly 'org.projectlombok:lombok'
4344
runtimeOnly 'com.h2database:h2'
4445
runtimeOnly 'mysql:mysql-connector-java'

src/main/resources/application.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ spring:
1212
use-new-id-generator-mappings: false
1313
properties:
1414
hibernate.dialect: org.hibernate.dialect.MySQL8Dialect
15+
profiles:
16+
include:
17+
- slack-logging
1518
server:
1619
port: 8080
1720
jwt:
@@ -30,3 +33,7 @@ cloud:
3033
static: ap-northeast-2
3134
stack:
3235
auto: false
36+
logging:
37+
slack:
38+
webhook-uri: https://hooks.slack.com/services/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 # SLACK_WEBHOOK_URI 추가
39+
config: classpath:logback-slack.xml
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<configuration>
3+
<springProperty name="SLACK_WEBHOOK_URI" source="logging.slack.webhook-uri"/>
4+
<appender name="SLACK" class="com.github.maricn.logback.SlackAppender">
5+
<webhookUri>${SLACK_WEBHOOK_URI}</webhookUri>
6+
<layout class="ch.qos.logback.classic.PatternLayout">
7+
<pattern>%-4relative [%thread] %-5level %class - %msg%n</pattern>
8+
</layout>
9+
<username>posting bot</username>
10+
<iconEmoji>:stuck_out_tongue_winking_eye:</iconEmoji>
11+
<colorCoding>true</colorCoding>
12+
</appender>
13+
<appender name="ASYNC_SLACK" class="ch.qos.logback.classic.AsyncAppender">
14+
<appender-ref ref="SLACK"/>
15+
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
16+
<level>ERROR</level>
17+
</filter>
18+
</appender>
19+
20+
<root>
21+
<springProfile name="slack-logging">
22+
<appender-ref ref="ASYNC_SLACK"/>
23+
</springProfile>
24+
</root>
25+
</configuration>

0 commit comments

Comments
 (0)