Skip to content

Commit

Permalink
feat: Update logging config
Browse files Browse the repository at this point in the history
  • Loading branch information
devmizz committed Aug 25, 2024
1 parent 1b9cd16 commit f0a7c61
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 72 deletions.
1 change: 1 addition & 0 deletions .github/workflows/showpot-dev-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- develop
- hotfix/**
- feat/config

jobs:
build-and-deploy:
Expand Down
104 changes: 49 additions & 55 deletions app/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -1,65 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<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="${CONSOLE_LOG_PATTERN:-%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} %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}}"/>

<springProperty name="ACTIVE_PROFILE" source="profile.active"/>
<springProperty name="AWS_ACCESS_KEY" source="cloud.aws.credentials.accessKey"/>
<springProperty name="AWS_SECRET_KEY" source="cloud.aws.credentials.secretKey"/>

<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>

<appender name="CloudWatchAppender" class="ca.pjer.logback.AwsLogsAppender">
<layout>
<pattern>[%thread] [%date] [%level] [%file:%line] - %msg%n</pattern>
</layout>
<!-- Information of Cloudwatch -->
<logGroupName>showpot/${ACTIVE_PROFILE}</logGroupName>
<logRegion>ap-northeast-2</logRegion>
<maxBatchLogEvents>50</maxBatchLogEvents>
<maxFlushTimeMillis>60000</maxFlushTimeMillis>
<maxBlockTimeMillis>5000</maxBlockTimeMillis>
<retentionTimeDays>0</retentionTimeDays>
<accessKeyId>${AWS_ACCESS_KEY}</accessKeyId>
<secretAccessKey>${AWS_SECRET_KEY}</secretAccessKey>

<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>

<encoder>
<charset>UTF-8</charset>
<pattern>%d{HH:mm:ss.SSS} [%thread] [%5level] %logger{35}[%method:%line] %m%n</pattern>
</encoder>
</appender>

<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="${CONSOLE_LOG_PATTERN:-%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} %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}}"/>

<springProperty name="ACTIVE_PROFILE" source="profile.active"/>
<springProperty name="AWS_ACCESS_KEY" source="cloud.aws.credentials.accessKey"/>
<springProperty name="AWS_SECRET_KEY" source="cloud.aws.credentials.secretKey"/>

<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>

<appender name="CloudWatchAppender" class="ca.pjer.logback.AwsLogsAppender">
<layout>
<pattern>[%thread] [%date] [%level] [%file:%line] - %msg%n</pattern>
</layout>
<!-- Information of Cloudwatch -->
<logGroupName>showpot/${ACTIVE_PROFILE}</logGroupName>
<logRegion>ap-northeast-2</logRegion>
<maxBatchLogEvents>50</maxBatchLogEvents>
<maxFlushTimeMillis>60000</maxFlushTimeMillis>
<maxBlockTimeMillis>5000</maxBlockTimeMillis>
<retentionTimeDays>0</retentionTimeDays>
<accessKeyId>${AWS_ACCESS_KEY}</accessKeyId>
<secretAccessKey>${AWS_SECRET_KEY}</secretAccessKey>

<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>

<encoder>
<charset>UTF-8</charset>
<pattern>%d{HH:mm:ss.SSS} [%thread] [%5level] %logger{35}[%method:%line] %m%n</pattern>
</encoder>
</appender>

<root level="info">
<springProfile name="local">
<root level="INFO">
<appender-ref ref="Console"/>
</root>
<appender-ref ref="Console"/>
</springProfile>

<springProfile name="dev">
<root level="INFO">
<appender-ref ref="CloudWatchAppender"/>
</root>
<appender-ref ref="CloudWatchAppender"/>
</springProfile>

<springProfile name="prod">
<root level="INFO">
<appender-ref ref="CloudWatchAppender"/>
</root>
<appender-ref ref="CloudWatchAppender"/>
</springProfile>
</root>
</configuration>
17 changes: 0 additions & 17 deletions app/src/main/resources/logback-test.xml

This file was deleted.

0 comments on commit f0a7c61

Please sign in to comment.