一、Spring Cloud Feign 请求压缩
#开启压缩compression:request:enabled: true # 开启请求压缩#最小触发压缩的大小min-request-size: 2048#触发压缩数据类型,(注意不能使用"" ,'')mime-types: text/xml, application/xml, application/jsonresponse:enabled: true # 开启响应压缩
二、Feign的日志级别配置
实现步骤:
- 在application.yml配置文件中开启日志级别配置
- 编写配置类,定义日志级别bean。
- 在接口的@FeignClient中指定配置类
- 重启项目,测试访问
1. 在application.yml配置文件中开启日志级别配置
#开启debug模式
debug: true
#配置日志级别
logging:level:com.william.service.Impl: debug
2. 编写配置类,定义日志级别bean。
package com.william.config;import feign.Logger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;/*** @author :lijunxuan* @date :Created in 2019/6/30 20:00* @description :* @version: 1.0*//*** 代表当前的类是一个配置类* ApplicationContext.xml*/
@Configuration
public class FeignConfig {/*** Bean相当于把当前对象注入到Spring容器当中* <Bean id ="" class=""></>* @return*/@Beanpublic Logger.Level feignLoggerLevel(){return Logger.Level.FULL;}/*** FULL Log the headers, body, and metadata for both requests and responses.* 全部:请求和响应的头、体、元数据*//*** Bean 把当前对象注入到spring容器中* <bean id= class=></>* @return*//*** NONE No logging.不做日志*//*** BASIC Log only the request method and URL and the response status code and execution time.* 仅仅是只记录请求方法,URL地址,响应状态码和执行时间*//*** HEADERS Log the basic information along with request and response headers.* headers:记录基本信息,请求和响应的头*/
}
3.在接口的@FeignClient中指定配置类
4. 重启项目,测试访问