-
Notifications
You must be signed in to change notification settings - Fork 4
Feature: HTTP 로깅 추가 #349
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
Feature: HTTP 로깅 추가 #349
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <configuration> | ||
| <logger name="org.springframework" level="INFO"/> | ||
| <logger name="springfox.documentation" level="ERROR"/> | ||
|
|
||
| </configuration> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,25 @@ | |
| classpath*:common/*.xml | ||
| </param-value> | ||
| </context-param> | ||
| <filter> | ||
| <filter-name>TeeFilter</filter-name> | ||
| <filter-class>ch.qos.logback.access.servlet.TeeFilter</filter-class> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TeeFilter 라는 Spring Filter (라이브러리에서 구현됨)에서 HTTP들을 캡쳐함. |
||
| <init-param> | ||
| <param-name>excludes</param-name> | ||
| <param-value>swagger-ui.html</param-value> | ||
| </init-param> | ||
| </filter> | ||
|
|
||
| <filter-mapping> | ||
| <filter-name>TeeFilter</filter-name> | ||
| <url-pattern>/*</url-pattern> | ||
| </filter-mapping> | ||
|
|
||
| <filter-mapping> | ||
| <filter-name>TeeFilter</filter-name> | ||
| <url-pattern>/swagger-ui.html</url-pattern> <!-- Add the URL pattern you want to exclude --> | ||
| <dispatcher>REQUEST</dispatcher> <!-- Exclude only request type --> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. swagger 문서를 응답해주는 경우 body(html)이 너무 길어져서, 해당 경우는 url pattern으로 로깅을 하지 않도록 함. |
||
| </filter-mapping> | ||
| <!-- Creates the Spring Container shared by all Servlets and Filters --> | ||
| <listener> | ||
| <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Spring3 에서는 이를 인식하지 못해서( |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <configuration> | ||
| <property name="LOG_PATH_NAME" value="${user.home}/http-access.log"/> | ||
| <property name="HTTP_PATTERN" value="%n-------- INFO --------%n- time: %t{yyyy-MM-dd HH:mm:ss}%n- summary: %a\t%r\t%s%n%n-------- HTTP REQUEST --------%n%header{Referer}\t%header{User-Agent}\t%D\t%I%n%fullRequest%n-------- HTTP RESPONSE --------%n%fullResponse%n--------%n"/> | ||
|
|
||
|
|
||
| <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
| <file>${LOG_PATH_NAME}/access.log</file> | ||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
| <fileNamePattern>${LOG_PATH_NAME}/access.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
| <maxHistory>30</maxHistory> | ||
| </rollingPolicy> | ||
| <encoder> | ||
| <pattern>${HTTP_PATTERN}</pattern> | ||
| </encoder> | ||
| </appender> | ||
|
|
||
| <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
| <encoder> | ||
| <pattern>${HTTP_PATTERN}</pattern> | ||
| </encoder> | ||
| </appender> | ||
|
|
||
| <logger name="org.springframework" level="ERROR"/> | ||
| <logger name="springfox.documentation" level="ERROR"/> | ||
| <logger name="springfox.documentation.schema.property.bean.BeanModelProperty" level="INFO"/> | ||
|
|
||
| <appender-ref ref="FILE"/> | ||
| <appender-ref ref="CONSOLE"/> | ||
| </configuration> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java버전별 logback 버전: https://logback.qos.ch/news.html