-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-logging 중앙 집중식 로깅 구현
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<configuration> | ||
<!-- AWS 자격증명 설정 --> | ||
<springProperty scope="context" name="AWS_ACCESS_KEY" source="cloud.aws.credentials.access-key"/> | ||
<springProperty scope="context" name="AWS_SECRET_KEY" source="cloud.aws.credentials.secret-key"/> | ||
|
||
<!-- 콘솔 로그 패턴 정의 --> | ||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/> | ||
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/> | ||
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/> | ||
<property name="CONSOLE_LOG_PATTERN" value="${LOG_PATTERN:-%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){blue} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> | ||
|
||
<!-- 콘솔에 로그를 출력해주는 ConsoleAppender 설정 --> | ||
<appender name="console_log" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>${CONSOLE_LOG_PATTERN}</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<!-- CloudWatch에 로그를 전송해주는 AwsLogsAppender 설정 --> | ||
<appender name="aws_cloud_watch_log" class="ca.pjer.logback.AwsLogsAppender"> | ||
<encoder> | ||
<pattern>[%thread] [%level] [%file:%line] - %msg%n</pattern> | ||
</encoder> | ||
<logGroupName>ec2-asg</logGroupName> | ||
<logStreamUuidPrefix>application-log-</logStreamUuidPrefix> | ||
<logRegion>ap-northeast-2</logRegion> | ||
<maxBatchLogEvents>50</maxBatchLogEvents> | ||
<maxFlushTimeMillis>30000</maxFlushTimeMillis> | ||
<maxBlockTimeMillis>5000</maxBlockTimeMillis> | ||
<retentionTimeDays>30</retentionTimeDays> | ||
<accessKeyId>${AWS_ACCESS_KEY}</accessKeyId> | ||
<secretAccessKey>${AWS_SECRET_KEY}</secretAccessKey> | ||
</appender> | ||
|
||
<!-- local 환경에서는 ConsoleAppender 사용 --> | ||
<springProfile name="local"> | ||
<root level="INFO"> | ||
<appender-ref ref="console_log"/> | ||
</root> | ||
</springProfile> | ||
|
||
<!-- dev 환경에서는 ConsoleAppender 사용 --> | ||
<springProfile name="dev"> | ||
<root level="INFO"> | ||
<appender-ref ref="console_log"/> | ||
</root> | ||
</springProfile> | ||
|
||
<!-- prod 환경에서는 AwsLogsAppender 사용 --> | ||
<springProfile name="prod"> | ||
<root level="INFO"> | ||
<appender-ref ref="aws_cloud_watch_log"/> | ||
</root> | ||
</springProfile> | ||
</configuration> |