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

chore: logback 설정 진행 #270

Merged
merged 4 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/backend-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
push:
branches: [ "develop-BE" ]
paths: [ "backend/**" ]
# pull_request:
# branches: [ "develop-BE" ]
# pull_request:
# branches: [ "develop-BE" ]

jobs:

Expand Down Expand Up @@ -63,4 +63,4 @@ jobs:
docker rm ${{ secrets.DOCKERHUB_CONTAINER_NAME }} | true
docker image prune -a -f
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:${GITHUB_SHA::7}
docker run --name ${{ secrets.DOCKERHUB_CONTAINER_NAME }} -d -p 80:8080 ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:${GITHUB_SHA::7}
docker run --name ${{ secrets.DOCKERHUB_CONTAINER_NAME }} -d -p 80:8080 -v /logs:/logs ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:${GITHUB_SHA::7}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ public class LoggingFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
if (isMultipart(request)) {
chain.doFilter(request, response);
}
HttpServletRequest wrappedRequest
= new CachedHttpServletRequestWrapper((HttpServletRequest) request);
CachedHttpServletResponseWrapper wrappedResponse
= new CachedHttpServletResponseWrapper((HttpServletResponse) response);
chain.doFilter(wrappedRequest, wrappedResponse);
wrappedResponse.copyBodyToResponse();
}

private boolean isMultipart(ServletRequest request) {
String contentType = request.getContentType();
return contentType != null && contentType.toLowerCase().startsWith("multipart/");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,5 @@ public void afterCompletion(HttpServletRequest request,
requestBody, statusCode, responseBody, latency);
log.warn(logResponse.toString());
}

}
}
13 changes: 13 additions & 0 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,16 @@ components:
type: apiKey
in: cookie
name: JSESSIONID

logging:
level:
com.zzang.chongdae: INFO
file:
name: /logs/backend.log
pattern:
file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
logback:
rollingpolicy:
file-name-pattern: /logs/backend.%d{yyyy-MM-dd}.%i.log
max-file-size: 100MB
max-history: 14