parent
c90e825bfd
commit
fbcba137fa
@ -0,0 +1,33 @@ |
|||||||
|
package com.example.demo.config; |
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.http.converter.HttpMessageConverter; |
||||||
|
import org.springframework.http.converter.StringHttpMessageConverter; |
||||||
|
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; |
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Configuration |
||||||
|
public class CustomMVCConfiguration implements WebMvcConfigurer { |
||||||
|
|
||||||
|
|
||||||
|
@Bean |
||||||
|
public HttpMessageConverter<String> responseBodyConverter() { |
||||||
|
return new StringHttpMessageConverter(StandardCharsets.UTF_8); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void configureMessageConverters( |
||||||
|
List<HttpMessageConverter<?>> converters) { |
||||||
|
converters.add(responseBodyConverter()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void configureContentNegotiation( |
||||||
|
ContentNegotiationConfigurer configurer) { |
||||||
|
configurer.favorPathExtension(false); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
<configuration debug="true"> |
||||||
|
|
||||||
|
<include resource="org/springframework/boot/logging/logback/defaults.xml" /> |
||||||
|
|
||||||
|
<property name="APP_NAME" value="Logback"/> |
||||||
|
<property name="LOG_HOME_PATH" value="logs"/> |
||||||
|
<property name="DEBUG_LOG_FILE" value="${LOG_HOME_PATH}/debug/${APP_NAME}_debug" /> |
||||||
|
<property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}" /> |
||||||
|
|
||||||
|
|
||||||
|
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||||
|
<encoder> |
||||||
|
<pattern>${FILE_LOG_PATTERN}</pattern> |
||||||
|
</encoder> |
||||||
|
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||||
|
<FileNamePattern>${DEBUG_LOG_FILE}.%d{yyyy-MM-dd}.log</FileNamePattern> |
||||||
|
<MaxHistory>60</MaxHistory> |
||||||
|
</rollingPolicy> |
||||||
|
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
||||||
|
<level>DEBUG</level> |
||||||
|
</filter> |
||||||
|
</appender> |
||||||
|
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> |
||||||
|
<encoder> |
||||||
|
<pattern>${FILE_LOG_PATTERN}</pattern> |
||||||
|
</encoder> |
||||||
|
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
||||||
|
<level>INFO</level> |
||||||
|
</filter> |
||||||
|
</appender> |
||||||
|
|
||||||
|
<root level="DEBUG"> |
||||||
|
<appender-ref ref="DEBUG_FILE" /> |
||||||
|
<appender-ref ref="CONSOLE" /> |
||||||
|
</root> |
||||||
|
</configuration> |
Loading…
Reference in new issue