Skip to content

Commit

Permalink
[#96] 엑츄에이터 로그 파일 추출하도록 설정 (#98)
Browse files Browse the repository at this point in the history
* refactor: favicon.ico 필터링 안거치게 수정

* feat: 엑추에이터 로그파일 경로 설정

* refactor: 도커 파일 볼륨 경로 수정

* refactor: WebSecurityCustomizer 설정 제거
  • Loading branch information
minsang-alt authored May 7, 2024
1 parent 626e5ce commit 8154761
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend-prod-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
ssh -i pem_key -o StrictHostKeyChecking=no ${{ secrets.WAS_USERNAME }}@${{ secrets.WAS_PUBLIC_IP }} << EOF
docker rm -f agilehub-backend || true
docker pull ${{ env.DOCKER_HUB_REPOSITORY }}:${{ github.sha }}
docker run -v prod-log:/app/log \
docker run -v prod-vol:/app \
--env-file .env \
-d -p 8080:8080 --name agilehub-backend ${{ env.DOCKER_HUB_REPOSITORY }}:${{ github.sha }}
EOF
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ private Authentication getAuthentication(SecurityMember securityMember) {
protected boolean shouldNotFilter(HttpServletRequest request) {
String path = request.getRequestURI();
return path.contains("/oauth2") || path.contains("/api-docs") || path.contains("/swagger-ui") || path.contains(
"/actuator");
"/actuator") || path.contains("/favicon.ico") || path.contains("/error");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
Expand All @@ -30,12 +29,6 @@ public class SpringSecurityConfig {

private final CustomOAuth2UserService customOAuth2UserService;

@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return web -> web.ignoring()
.requestMatchers("/error", "/favicon.ico");
}

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {

Expand All @@ -58,7 +51,8 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.logout(AbstractHttpConfigurer::disable)
// requestMatchers 설정
.authorizeHttpRequests(requests -> requests
.requestMatchers("/oauth2/**", "/auth/success/**", "*/api-docs/**", "/swagger-ui/**", "/actuator/**")
.requestMatchers("/oauth2/**", "/auth/success/**", "*/api-docs/**", "/swagger-ui/**", "/actuator/**",
"/favicon.ico")
.permitAll()
.anyRequest().authenticated()
)
Expand Down
13 changes: 12 additions & 1 deletion src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,15 @@ spring:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
default_batch_fetch_size: 100
open-in-view: false
open-in-view: false

management:
endpoints:
web:
exposure:
include: [ "prometheus", "logfile" ]
endpoint:
prometheus:
enabled: true
logfile:
external-file: ./logs/agilehub-prod.log
8 changes: 0 additions & 8 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,3 @@ aws:
workingDirectory:
issue: issue

management:
endpoints:
web:
exposure:
include: prometheus
endpoint:
prometheus:
enabled: true
5 changes: 4 additions & 1 deletion src/main/resources/file-error-appender.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<included>
<property name="LOG_PATH" value="./logs"/>

<appender name="FILE-ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
Expand All @@ -8,8 +10,9 @@
<encoder>
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
<file>./logs/agilehub-prod.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>./log/agileHub-prod-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<fileNamePattern>${LOG_PATH}/old/agilehub-prod-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>7</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
Expand Down

0 comments on commit 8154761

Please sign in to comment.