Skip to content

Commit

Permalink
♻️ batch server에서 로그 받도록 socket-server 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
semi-cloud committed Dec 1, 2024
1 parent baf5130 commit 8c77aa5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
7 changes: 4 additions & 3 deletions application/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,16 @@
<appender name="HASHTAG_SOCKET" class="ch.qos.logback.classic.net.SocketAppender">
<remoteHost>${HASHTAG_LOG_HOST_NAME}</remoteHost>
<port>${HASHTAG_LOG_PORT}</port>
<!-- <includeCallerData>true</includeCallerData>-->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${HASHTAG_LOG_PATTERN}</pattern>
</encoder>
</appender>

<appender name="HASHTAG_ASYNC_SOCKET" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>512</queueSize> <!-- 로그 버퍼 크기 -->
<discardingThreshold>0</discardingThreshold> <!-- 큐가 가득 찼을 때 버릴 로그 수준 설정 -->
<neverBlock>true</neverBlock> <!-- 큐가 가득 차도 메인 스레드가 차단되지 않도록 설정 -->
<queueSize>512</queueSize>
<discardingThreshold>0</discardingThreshold>
<neverBlock>true</neverBlock>
<appender-ref ref="HASHTAG_SOCKET"/>
</appender>

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/logback.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ log.config.error.path=./error_logs
log.config.error.filename=error_log
log.config.error.archive.path=./error_logs/archive

log.config.hashtag.path=./logs/archive/hashtag
log.config.hashtag.path=./scheduler/logs/archive/hashtag
log.config.hashtag.filename=hashtag_log
log.config.hashtag.hostname=internal.scheduler
log.config.hashtag.hostname.local=localhost
log.config.hashtag.port=8080
log.config.hashtag.port=5001
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package backend.team.ahachul_backend

import backend.team.ahachul_backend.common.properties.SocketServerProperties
import ch.qos.logback.classic.net.SimpleSocketServer
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.runApplication
import org.springframework.context.ApplicationContext

@SpringBootApplication
@EnableConfigurationProperties
class ScheduleModuleApplication

fun main(args: Array<String>) {
runApplication<ScheduleModuleApplication>(*args)
val context: ApplicationContext = runApplication<ScheduleModuleApplication>(*args)
val properties = context.getBean(SocketServerProperties::class.java)
SimpleSocketServer.main(arrayOf(properties.port, properties.configPath))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package backend.team.ahachul_backend.common.properties

import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.context.annotation.Configuration

@Configuration
@ConfigurationProperties(prefix = "socket-server")
data class SocketServerProperties(
var port: String = "",
var configPath: String = ""
)
6 changes: 6 additions & 0 deletions scheduler/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
</rollingPolicy>
</appender>

<root level="{LOG_LEVEL}">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
<appender-ref ref="ERROR_FILE"/>
</root>

<logger name="HASHTAG_LOGGER" LEVEL="INFO">
<appender-ref ref="HASHTAG_FILE"/>
</logger>
Expand Down

0 comments on commit 8c77aa5

Please sign in to comment.