Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 타입
구현한 기능
테스트 결과
성공!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
로그 내용 중복 없음 또한 확인 완료
서버 종료시 파일 업로드 확인
매일 정각 파일 업로드 확인 완료

코드 설명
설정 파일 경로를 명시적으로 지정할 때는 애플리케이션이 실행 중인 환경에서 접근 가능한 절대 경로를 사용해야 합니다. src/main/resources/logback-spring.xml은 소스 코드 경로이고, 빌드된 애플리케이션은 이 경로를 사용할 수 없습니다.
그래서, loggerContext.doConfigure(...)와 같은 메서드에 파일 경로를 전달할 때는 애플리케이션이 접근할 수 있는 절대 경로를 사용해야 하는데, Logback 설정 파일이 클래스패스에 포함되어 있다면, 아래처럼 접근 가능합니다!
configurator.doConfigure(getClass().getClassLoader().getResource("logback-spring.xml"));만일, 설정 파일이 /var/app/current/logback-spring.xml과 같은 시스템 경로에 있다면, 절대 경로를 사용할 수 있습니다.
configurator.doConfigure("/var/app/current/logback-spring.xml");이처럼, Logback 설정 파일이 애플리케이션 배포 시 외부 경로( JAR 외부)로 복사된다면, 해당 경로를 명시적으로 지정해야 합니다.
클래스패스를 사용하는 방식은 소스 코드 관리와 배포 간소화에 유리하며, 절대 경로는 외부 설정 파일 관리에 적합합니다.
클래스패스 접근의 이점
src/main/resources에 위치한 파일은 애플리케이션이 빌드될 때 자동으로 클래스패스에 포함됩니다. JAR 파일 내부에서도 동일한 방식으로 접근할 수 있어, 로컬 개발 환경과 배포 환경 간의 차이가 없습니다.
하지만, 절대 경로(/var/...)를 사용하는 방식은 특정 환경에 종속적이어서, 다른 환경에서 실행 시 문제가 발생할 가능성이 있습니다.