Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/78 Logging #97

Merged
merged 2 commits into from
Oct 3, 2023
Merged

feat/78 Logging #97

merged 2 commits into from
Oct 3, 2023

Conversation

minjun3021
Copy link
Collaborator

@minjun3021 minjun3021 commented Oct 1, 2023

What is this PR?

Key Changes

기존 스프링부트의 로그 형식을 맞추되 ,
어떤 request에서 생기는 로그인지를 구분하기위해 요청마다 UUID와, 요청한 유저의 아이디를 같이 로그에 찍는다.

로그 설정은 resources/logback-spring.xml에서 확인할수있으며
로그 파일 저장 정책도 확인할수있다.

<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>./logs/logback-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
        <maxHistory>30</maxHistory>
        <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>100MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>

log pattern

Test Checklist

@junha-ahn
Copy link
Member

에러의 경우 Trace 출력해주세요.

@junha-ahn
Copy link
Member

  1. Request 를 처음 만나는 포인트에서 URI (query, params 포함), Request Body, Token Data를 담아서 로그를 남기고
  2. 다음부터는 UserId를 로그에 포함하지 않고 그냥 로그(UUID포함)만 남겨도 될 것 같습니다

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (ff28981) 84.21% compared to head (35e9d24) 84.90%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #97      +/-   ##
============================================
+ Coverage     84.21%   84.90%   +0.69%     
- Complexity      125      135      +10     
============================================
  Files            40       41       +1     
  Lines           551      583      +32     
  Branches         10       15       +5     
============================================
+ Hits            464      495      +31     
  Misses           78       78              
- Partials          9       10       +1     
Files Coverage Δ
...in/com/group4/ticketingservice/config/WebConfig.kt 100.00% <100.00%> (ø)
...ticketingservice/filter/JwtAuthenticationFilter.kt 93.93% <ø> (ø)
...gservice/utils/exception/GlobalExceptionHandler.kt 65.21% <100.00%> (+1.03%) ⬆️
...in/com/group4/ticketingservice/filter/LogFilter.kt 96.15% <96.15%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@minjun3021
Copy link
Collaborator Author

Sevlet 특성상 content를 한번 밖에 읽지 못해서
logging을 할때 requestBody를 같이 찍으려면
httpservletrequest를 wrapping을 해야해서
log찍는 위치를 interceptor에서 filter로 변경하였습니다. requestBody는 요청에대한 처리가 끝나고 캐싱된 값으로 로그에 찍힙니다

Copy link
Collaborator

@ParkJeongseop ParkJeongseop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@junha-ahn junha-ahn merged commit 786bcee into main Oct 3, 2023
10 checks passed
@junha-ahn junha-ahn deleted the feat/78-logging branch October 3, 2023 06:40
This was linked to issues Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

로그 기능 구현 API 기능 고도화
3 participants