-
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.
Merge pull request #109 from LikeKNU/Chore/Logback
chore: configure logback pattern and appender by active profiles
- Loading branch information
Showing
10 changed files
with
110 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,6 @@ on: | |
push: | ||
branches: | ||
- main | ||
# pull_request: | ||
# branches: | ||
# - main | ||
|
||
jobs: | ||
deploy: | ||
|
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
#!/bin/bash | ||
|
||
ROOT_PATH="/home/ec2-user/deploy" | ||
JAR="$ROOT_PATH/application.jar" | ||
ROOT_PATH="/home/ec2-user/LikeKNU" | ||
JAR="$ROOT_PATH/LikeKNU.jar" | ||
|
||
APP_LOG="$ROOT_PATH/application.log" | ||
ERROR_LOG="$ROOT_PATH/error.log" | ||
START_LOG="$ROOT_PATH/start.log" | ||
|
||
NOW=$(date +%c) | ||
|
||
echo "[$NOW] $JAR 복사" >> $START_LOG | ||
cp $ROOT_PATH/build/libs/LikeKNU-1.0.0.jar $JAR | ||
echo "[$NOW] Copy $JAR" >> $START_LOG | ||
cp $ROOT_PATH/build/libs/*.jar $JAR | ||
|
||
echo "[$NOW] > $JAR 실행" >> $START_LOG | ||
echo "[$NOW] Run $JAR" >> $START_LOG | ||
source ~/.bash_profile | ||
nohup java -jar $JAR > $APP_LOG 2> $ERROR_LOG & | ||
nohup java -jar $JAR --spring.profiles.active=prod > $APP_LOG 2> $ERROR_LOG & | ||
|
||
SERVICE_PID=$(pgrep -f $JAR) | ||
echo "[$NOW] > 서비스 PID: $SERVICE_PID" >> $START_LOG | ||
echo "[$NOW] Application PID: $SERVICE_PID" >> $START_LOG |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
#!/bin/bash | ||
|
||
ROOT_PATH="/home/ec2-user/deploy" | ||
JAR="$ROOT_PATH/application.jar" | ||
ROOT_PATH="/home/ec2-user/LikeKNU" | ||
JAR="$ROOT_PATH/LikeKNU.jar" | ||
STOP_LOG="$ROOT_PATH/stop.log" | ||
SERVICE_PID=$(pgrep -f $JAR) | ||
|
||
if [ -z "$SERVICE_PID" ]; then | ||
echo "서비스 NotFound" >> $STOP_LOG | ||
echo "Service not found" >> $STOP_LOG | ||
else | ||
echo "서비스 종료 " >> $STOP_LOG | ||
echo "Terminate service " >> $STOP_LOG | ||
kill -9 "$SERVICE_PID" | ||
fi |
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,8 @@ | ||
<included> | ||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>${LOG_PATTERN}</pattern> | ||
<charset>utf8</charset> | ||
</encoder> | ||
</appender> | ||
</included> |
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,20 @@ | ||
<included> | ||
<appender name="FILE-ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>${DEFAULT_DIR}/log/error/error-${BY_DATE}.log</file> | ||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | ||
<level>ERROR</level> | ||
<onMatch>ACCEPT</onMatch> | ||
<onMismatch>DENY</onMismatch> | ||
</filter> | ||
<encoder> | ||
<pattern>${LOG_FILE_PATTERN}</pattern> | ||
<charset>utf8</charset> | ||
</encoder> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | ||
<fileNamePattern>${DEFAULT_DIR}/backup/error/error-%d{yyyy-MM-dd}.%i.gz</fileNamePattern> | ||
<maxFileSize>50MB</maxFileSize> | ||
<maxHistory>30</maxHistory> | ||
<totalSizeCap>2GB</totalSizeCap> | ||
</rollingPolicy> | ||
</appender> | ||
</included> |
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,20 @@ | ||
<included> | ||
<appender name="FILE-INFO" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>${DEFAULT_DIR}/log/info/info-${BY_DATE}.log</file> | ||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
<level>INFO</level> | ||
<onMatch>ACCEPT</onMatch> | ||
<onMismatch>DENY</onMismatch> | ||
</filter> | ||
<encoder> | ||
<pattern>${LOG_FILE_PATTERN}</pattern> | ||
<charset>utf8</charset> | ||
</encoder> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | ||
<fileNamePattern>${DEFAULT_DIR}/backup/info/info-%d{yyyy-MM-dd}.%i.gz</fileNamePattern> | ||
<maxFileSize>50MB</maxFileSize> | ||
<maxHistory>30</maxHistory> | ||
<totalSizeCap>2GB</totalSizeCap> | ||
</rollingPolicy> | ||
</appender> | ||
</included> |
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,20 @@ | ||
<included> | ||
<appender name="FILE-WARN" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>${DEFAULT_DIR}/log/warn/warn-${BY_DATE}.log</file> | ||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | ||
<level>WARN</level> | ||
<onMatch>ACCEPT</onMatch> | ||
<onMismatch>DENY</onMismatch> | ||
</filter> | ||
<encoder> | ||
<pattern>${LOG_FILE_PATTERN}</pattern> | ||
<charset>utf8</charset> | ||
</encoder> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | ||
<fileNamePattern>${DEFAULT_DIR}/backup/warn/warn-%d{yyyy-MM-dd}.%i.gz</fileNamePattern> | ||
<maxFileSize>50MB</maxFileSize> | ||
<maxHistory>30</maxHistory> | ||
<totalSizeCap>2GB</totalSizeCap> | ||
</rollingPolicy> | ||
</appender> | ||
</included> |
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,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<configuration> | ||
<timestamp key="BY_DATE" datePattern="yyyy-MM-dd" /> | ||
<property name="LOG_PATTERN" | ||
value="%green([%d{yyyy-MM-dd HH:mm:ss.SSS}]) %magenta([%22.22thread]) %highlight(%-5level) | %yellow(%50.50logger{50}) | %msg%n" /> | ||
<property name="LOG_FILE_PATTERN" | ||
value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%22.22thread] %-5level | %50.50logger{50} | %msg%n" /> | ||
<property name="DEFAULT_DIR" value="/home/ec2-user/LikeKNU" /> | ||
|
||
<springProfile name="dev"> | ||
<include resource="console-appender.xml" /> | ||
<root level="INFO"> | ||
<appender-ref ref="CONSOLE" /> | ||
</root> | ||
</springProfile> | ||
|
||
<springProfile name="prod"> | ||
<include resource="file-info-appender.xml" /> | ||
<include resource="file-warn-appender.xml" /> | ||
<include resource="file-error-appender.xml" /> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="FILE-INFO" /> | ||
<appender-ref ref="FILE-WARN" /> | ||
<appender-ref ref="FILE-ERROR" /> | ||
</root> | ||
|
||
</springProfile> | ||
</configuration> |