Skip to content

Commit

Permalink
feat : sentry 및 로깅 전략 결정 (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjunYou authored Mar 30, 2024
1 parent 5aea98f commit 4accef0
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
implementation 'org.apache.poi:poi-ooxml:5.2.0'
implementation 'org.springframework.boot:spring-boot-configuration-processor'

implementation 'io.sentry:sentry-logback:7.6.0'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import lombok.RequiredArgsConstructor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ jwt:
issuer: "ddingdong"
secret: ${JWT_SECRET}
expiration: 36000

sentry:
dsn: ${SENTRY_DSN_KEY}
enable-tracing: true
environment: dev
5 changes: 5 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ cloud:
static: ${AWS_DEFAULT_REGION}
stack:
auto: false

sentry:
dsn: ${SENTRY_KEY}
enable-tracing: true
environment: dev
7 changes: 7 additions & 0 deletions src/main/resources/console-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<included>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>
</included>
16 changes: 16 additions & 0 deletions src/main/resources/file-error-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<included>
<appender name="FILE-ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
</filter>
<encoder>
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>./log/pium-prod-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>50</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
</appender>
</included>
13 changes: 13 additions & 0 deletions src/main/resources/file-info-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<included>
<appender name="FILE-INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>./log/pium-dev-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>100</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
</appender>
</included>
29 changes: 29 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="CONSOLE_LOG_PATTERN"
value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %clr(%5level) %cyan(%logger) - %msg%n"/>
<property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %5level %logger - %msg%n"/>

<springProfile name="local">
<include resource="console-appender.xml"/>

<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>

<springProfile name="dev">
<include resource="file-info-appender.xml"/>
<include resource="file-error-appender.xml"/>
<include resource="sentry-appender.xml"/>

<root level="INFO">
<appender-ref ref="FILE-INFO"/>
</root>

<root level="ERROR">
<appender-ref ref="FILE-ERROR"/>
<appender-ref ref="SENTRY"/>
</root>
</springProfile>
</configuration>
8 changes: 8 additions & 0 deletions src/main/resources/sentry-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<appender name="SENTRY" class="io.sentry.logback.SentryAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

0 comments on commit 4accef0

Please sign in to comment.