當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Spring Cloud Feign 请求压缩 、Feign的日志级别配置
生活随笔
收集整理的這篇文章主要介紹了
Spring Cloud Feign 请求压缩 、Feign的日志级别配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、Spring Cloud Feign 請求壓縮
#開啟壓縮compression:request:enabled: true # 開啟請求壓縮#最小觸發壓縮的大小min-request-size: 2048#觸發壓縮數據類型,(注意不能使用"" ,'')mime-types: text/xml, application/xml, application/jsonresponse:enabled: true # 開啟響應壓縮二、Feign的日志級別配置
實現步驟:
1. 在application.yml配置文件中開啟日志級別配置
#開啟debug模式 debug: true #配置日志級別 logging:level:com.william.service.Impl: debug2. 編寫配置類,定義日志級別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. 重啟項目,測試訪問
總結
以上是生活随笔為你收集整理的Spring Cloud Feign 请求压缩 、Feign的日志级别配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为何访问不了对方电脑(为何访问不了对方电
- 下一篇: 网关 Spring Cloud Gate