-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from hanghae-plus-2nd/develop
feat : 로깅 MDC 설정
- Loading branch information
Showing
22 changed files
with
156 additions
and
14 deletions.
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
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
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/hanghae/four/taxiservice/domain/taxi/call/CallingClients.kt
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,5 @@ | ||
package hanghae.four.taxiservice.domain.taxi.call | ||
|
||
data class CallingClients( | ||
val clientIdList: List<Long>?, | ||
) |
2 changes: 1 addition & 1 deletion
2
...axiservice/util/annotations/Annotaions.kt → ...iservice/global/annotations/Annotaions.kt
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
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/hanghae/four/taxiservice/global/config/AsyncConfig.kt
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,21 @@ | ||
package hanghae.four.taxiservice.global.config | ||
|
||
import hanghae.four.taxiservice.global.decorator.LoggingTaskDecorator | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.core.task.TaskExecutor | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor | ||
|
||
@Configuration | ||
class AsyncConfig { | ||
@Bean | ||
fun taskExecutor(): TaskExecutor { | ||
val taskExecutor = ThreadPoolTaskExecutor() | ||
taskExecutor.corePoolSize = 20 | ||
taskExecutor.maxPoolSize = 50 | ||
taskExecutor.queueCapacity = 200 | ||
taskExecutor.setTaskDecorator(LoggingTaskDecorator()) | ||
|
||
return taskExecutor | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ur/taxiservice/util/config/RetryConfig.kt → .../taxiservice/global/config/RetryConfig.kt
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
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/hanghae/four/taxiservice/global/decorator/LoggingTaskDecorator.kt
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,14 @@ | ||
package hanghae.four.taxiservice.global.decorator | ||
|
||
import org.slf4j.MDC | ||
import org.springframework.core.task.TaskDecorator | ||
|
||
class LoggingTaskDecorator : TaskDecorator { | ||
override fun decorate(runnable: Runnable): Runnable { | ||
val context = MDC.getCopyOfContextMap() | ||
return Runnable { | ||
MDC.setContextMap(context) | ||
runnable.run() | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/hanghae/four/taxiservice/global/filter/MdcLoggingFilter.kt
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,22 @@ | ||
package hanghae.four.taxiservice.global.filter | ||
|
||
import org.slf4j.MDC | ||
import org.springframework.core.Ordered | ||
import org.springframework.core.annotation.Order | ||
import org.springframework.stereotype.Component | ||
import java.util.UUID | ||
import javax.servlet.Filter | ||
import javax.servlet.FilterChain | ||
import javax.servlet.ServletRequest | ||
import javax.servlet.ServletResponse | ||
|
||
@Component | ||
@Order(Ordered.HIGHEST_PRECEDENCE) | ||
class MdcLoggingFilter : Filter { | ||
override fun doFilter(request: ServletRequest?, response: ServletResponse?, chain: FilterChain?) { | ||
val uuid = UUID.randomUUID() | ||
MDC.put("request_id", uuid.toString()) | ||
chain?.doFilter(request, response) | ||
MDC.clear() | ||
} | ||
} |
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
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
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,31 @@ | ||
<configuration> | ||
<springProfile name="prod"> | ||
<appender name="taxiCloudwatchAppender" | ||
class="ca.pjer.logback.AwsLogsAppender"> | ||
<layout> | ||
<pattern>[%thread] [%date] [%level] [%file:%line] - %msg%n</pattern> | ||
</layout> | ||
<logGroupName>/ecs/hanghea-taxi</logGroupName> | ||
<logStreamUuidPrefix>cloudwatch-log-example-</logStreamUuidPrefix> | ||
<logRegion>ap-northeast-2</logRegion> | ||
<maxBatchLogEvents>50</maxBatchLogEvents> | ||
<maxFlushTimeMillis>30000</maxFlushTimeMillis> | ||
<maxBlockTimeMillis>5000</maxBlockTimeMillis> | ||
<retentionTimeDays>0</retentionTimeDays> | ||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
<level>INFO</level> | ||
<level>WARN</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"> | ||
<appender-ref ref="taxiCloudwatchAppender"/> | ||
</root> | ||
<root level="WARN"> | ||
<appender-ref ref="taxiCloudwatchAppender"/> | ||
</root> | ||
</springProfile> | ||
</configuration> |
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