Skip to content

Commit

Permalink
[NO_JIRA] loki 오류 fix (#134)
Browse files Browse the repository at this point in the history
* fix : loki 오류 fix

* refactor : Loki appender 파일 분리
  • Loading branch information
wjdwnsdnjs13 authored Aug 14, 2024
1 parent 5faa9e8 commit 716e787
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
15 changes: 15 additions & 0 deletions application/src/main/resources/appenders/console-appender.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,19 @@
<minimumEventLevel>ERROR</minimumEventLevel>
</appender>

<appender name="LOKI_APPENDER" class="com.github.loki4j.logback.Loki4jAppender">
<http>
<url>http://${LOKI_URL}:3100/loki/api/v1/push</url>
</http>
<format>
<label>
<pattern>app=${name},host=${HOSTNAME},level=%level</pattern>
<readMarkers>true</readMarkers>
</label>
<message>
<pattern>%highlight([%-5level]) %d{yy-MM-dd HH:mm:ss.SSS} %green([%thread]) %yellow([traceId=%X{traceId}]) %cyan([%logger{0}:%line])-%message%n</pattern>
</message>
<sortByTime>true</sortByTime>
</format>
</appender>
</included>
20 changes: 3 additions & 17 deletions application/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="5 seconds">
<include resource="appenders/console-appender.xml"/>
<property name="loki.url" value="${LOKI_URL:-localhost}" />
<springProfile name="local">
<root level="INFO">
<appender-ref ref="CONSOLE_APPENDER"/>
<appender-ref ref="LOKI_APPENDER"/>
</root>
</springProfile>

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

<springProfile name="prod">
<root level="ERROR">
<appender-ref ref="CONSOLE_APPENDER"/>
<appender-ref ref="SENTRY_APPENDER"/>

<appender name="LOKI_APPENDER" class="com.github.loki4j.logback.Loki4jAppender">
<http>
<url>http://${loki.url}:3100/loki/api/v1/push</url>
</http>
<format>
<label>
<pattern>app=${name},host=${HOSTNAME},level=%level</pattern>
<readMarkers>true</readMarkers>
</label>
<message>
<pattern>%highlight([%-5level]) %d{yy-MM-dd HH:mm:ss.SSS} %green([%thread]) %yellow([traceId=%X{traceId}]) %cyan([%logger{0}:%line])-%message%n</pattern>
</message>
<sortByTime>true</sortByTime>
</format>
</appender>
<appender-ref ref="LOKI_APPENDER"/>
</root>
</springProfile>
</configuration>

0 comments on commit 716e787

Please sign in to comment.