-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Sentry와 SpringBoot 로깅 프레임워크(log4j2) 연동 #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3dee9b2
60cb0d1
24f1076
bc434c7
b5c1597
551e575
f6eafc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,9 @@ spring: | |
| max-file-size: 10MB | ||
| max-request-size: 30MB | ||
|
|
||
| app: | ||
| module-name: batch | ||
|
|
||
| --- | ||
| spring: | ||
| config: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package org.yapp.infra.config.external.sentry | ||
|
|
||
| import io.sentry.Sentry | ||
| import io.sentry.SentryOptions | ||
| import org.springframework.beans.factory.annotation.Value | ||
| import org.springframework.boot.context.properties.EnableConfigurationProperties | ||
| import org.springframework.context.annotation.Bean | ||
| import org.springframework.context.annotation.Configuration | ||
| import org.yapp.infra.InfraBaseConfig | ||
|
|
||
| @Configuration | ||
| @EnableConfigurationProperties(SentryProperties::class) | ||
| class SentryConfig( | ||
| private val sentryProperties: SentryProperties, | ||
| @Value("\${app.module-name}") | ||
| private val moduleName: String | ||
| ) : InfraBaseConfig { | ||
|
|
||
| @Bean | ||
| fun sentryOptionsCustomizer(): Sentry.OptionsConfiguration<SentryOptions> { | ||
| return Sentry.OptionsConfiguration { options: SentryOptions -> | ||
| if (sentryProperties.dsn.isBlank()) { | ||
| options.isEnabled = false | ||
| return@OptionsConfiguration | ||
| } | ||
|
|
||
| options.dsn = sentryProperties.dsn | ||
| options.environment = sentryProperties.environment | ||
| options.serverName = sentryProperties.serverName | ||
| options.setTag("module", moduleName) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package org.yapp.infra.config.external.sentry | ||
|
|
||
| import org.springframework.boot.context.properties.ConfigurationProperties | ||
|
|
||
| @ConfigurationProperties(prefix = "sentry") | ||
| data class SentryProperties( | ||
| val dsn: String, | ||
| val environment: String, | ||
| val serverName: String, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,18 @@ logging: | |
| controller: | ||
| enabled: true | ||
|
|
||
| sentry: | ||
| dsn: ${SENTRY_DSN} | ||
| environment: ${SENTRY_ENVIRONMENT} | ||
| server-name: ${SENTRY_SERVER_NAME} | ||
| traces-sample-rate: 1.0 | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| send-default-pii: true | ||
| logs: | ||
| enabled: true | ||
| logging: | ||
| minimum-event-level: error | ||
| minimum-breadcrumb-level: info | ||
|
Comment on lines
+18
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. send-default-pii true 설정은 개인정보 보호 정책을 위반할 수 있습니다
- send-default-pii: true
+ send-default-pii: false
...
- send-default-pii: true
+ send-default-pii: falseAlso applies to: 46-51 🤖 Prompt for AI Agents |
||
|
|
||
| --- | ||
| spring: | ||
| config: | ||
|
|
@@ -25,3 +37,15 @@ logging: | |
| max-log-length: 500 | ||
| controller: | ||
| enabled: true | ||
|
|
||
| sentry: | ||
| dsn: | ||
| environment: test | ||
| server-name: reed-test | ||
| traces-sample-rate: 1.0 | ||
| send-default-pii: true | ||
| logs: | ||
| enabled: true | ||
| logging: | ||
| minimum-event-level: error | ||
| minimum-breadcrumb-level: info | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,14 +2,7 @@ | |||||||||||||||||
| <Configuration status="WARN"> | ||||||||||||||||||
|
|
||||||||||||||||||
| <Properties> | ||||||||||||||||||
| <!-- 색상 없는 기본 패턴 (파일용) --> | ||||||||||||||||||
| <Property name="FILE_LOG_PATTERN"> | ||||||||||||||||||
| %d{yyyy-MM-dd HH:mm:ss.SSSSSS} %-5level [%thread] [%X{traceId}] [%X{userId}] [%X{clientIp}] [%X{requestInfo}] %logger{36} - %msg%n | ||||||||||||||||||
| </Property> | ||||||||||||||||||
|
|
||||||||||||||||||
| <Property name="CONSOLE_LOG_PATTERN"> | ||||||||||||||||||
| %d{yyyy-MM-dd HH:mm:ss.SSSSSS} %highlight{%-5level}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=green, DEBUG=green bold, TRACE=blue} %style{[%thread]}{cyan} %style{[%X{traceId}]}{green} %style{[%X{userId}]}{magenta} %style{[%X{clientIp}]}{blue} %style{[%X{requestInfo}]}{yellow} %style{%logger{36}}{bright,white} - %msg%n | ||||||||||||||||||
| </Property> | ||||||||||||||||||
| <Property name="CONSOLE_LOG_PATTERN">%d{yyyy-MM-dd HH:mm:ss.SSSSSS} %highlight{%-5level}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=green, DEBUG=green bold, TRACE=blue} %style{[%thread]}{cyan} %style{[%X{traceId}]}{green} %style{[%X{userId}]}{magenta} %style{[%X{clientIp}]}{blue} %style{[%X{requestInfo}]}{yellow} %style{%logger{36}}{bright,white} - %msg%n</Property> | ||||||||||||||||||
| </Properties> | ||||||||||||||||||
|
|
||||||||||||||||||
| <Appenders> | ||||||||||||||||||
|
|
@@ -18,29 +11,21 @@ | |||||||||||||||||
| <PatternLayout pattern="${CONSOLE_LOG_PATTERN}" disableAnsi="false"/> | ||||||||||||||||||
| </Console> | ||||||||||||||||||
|
|
||||||||||||||||||
| <!-- 파일 출력 - 색상 없음 --> | ||||||||||||||||||
| <RollingFile name="FileAppender" fileName="logs/application.log" | ||||||||||||||||||
| filePattern="logs/application-%d{yyyy-MM-dd}-%i.log.gz"> | ||||||||||||||||||
| <PatternLayout pattern="${FILE_LOG_PATTERN}"/> | ||||||||||||||||||
| <Policies> | ||||||||||||||||||
| <TimeBasedTriggeringPolicy interval="1"/> | ||||||||||||||||||
| <SizeBasedTriggeringPolicy size="100MB"/> | ||||||||||||||||||
| </Policies> | ||||||||||||||||||
| <DefaultRolloverStrategy max="10"/> | ||||||||||||||||||
| </RollingFile> | ||||||||||||||||||
| <!-- Sentry Appender --> | ||||||||||||||||||
| <Sentry name="Sentry" dsn="${spring:sentry.dsn}"/> | ||||||||||||||||||
| </Appenders> | ||||||||||||||||||
|
Comment on lines
+14
to
16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sentry Appender의 level 속성이 무시되어 경고 로그가 발생합니다 Log4j2의 Sentry 플러그인은 - <Sentry name="Sentry" level="ERROR"/>
+ <Sentry name="Sentry">
+ <Filter type="ThresholdFilter" level="error"/>
+ </Sentry>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| <Loggers> | ||||||||||||||||||
| <!-- 내 애플리케이션 로거 --> | ||||||||||||||||||
| <Logger name="org.yapp" level="INFO" additivity="false"> | ||||||||||||||||||
| <AppenderRef ref="Console"/> | ||||||||||||||||||
| <AppenderRef ref="FileAppender"/> | ||||||||||||||||||
| <AppenderRef ref="Sentry"/> | ||||||||||||||||||
| </Logger> | ||||||||||||||||||
|
|
||||||||||||||||||
| <!-- 루트 로거 --> | ||||||||||||||||||
| <Root level="INFO"> | ||||||||||||||||||
| <AppenderRef ref="Console"/> | ||||||||||||||||||
| <AppenderRef ref="FileAppender"/> | ||||||||||||||||||
| <AppenderRef ref="Sentry"/> | ||||||||||||||||||
| </Root> | ||||||||||||||||||
| </Loggers> | ||||||||||||||||||
| </Configuration> | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sentry 옵션 커스터마이저 타입이 잘못되어 적용되지 않습니다
현재
@Bean이Sentry.OptionsConfiguration을 반환하고 있어 Spring Boot Starter가 제공하는 커스터마이저 체인에 연결되지 않습니다. 그 결과module태그 주입과 DSN 미설정 시 비활성화 로직이 전혀 실행되지 않습니다.io.sentry.spring.boot.jakarta.SentryOptionsConfiguration을 반환하도록 수정해야 합니다.🤖 Prompt for AI Agents