当前位置:网站首页>[cloud native] record of feign custom configuration of microservices
[cloud native] record of feign custom configuration of microservices
2022-07-26 05:35:00 【Hua Weiyun】
Preface :
Recently, I am learning about micro Services , Read the relevant courses of dark horse , Will relate Feign The knowledge of has summed up some , I hope I can help you guys and deepen your impression
If there is anything to be improved in the article, please give me more advice
Xiao Wei first thanked everyone for their support 
@[toc]
🥤Feign Custom configuration for
Feign There are two ways to customize the configuration :java Code configuration and Attribute configuration , These two configurations are described below .
Here we start with Feign Log configuration is an example ,Feign No logs are printed by default , When an exception occurs in the remote call , Subsequent debugging will want to see the details of the entire request , You can configure Feign Log requests .
Feign Log level of
1.NONE( The default value is ): Don't log anything
2.BASIC: Only the request method is recorded 、URL、 Response status code and execution time
3.HEADERS: Record BASIC Level based , Recording requests and responses header
4.FULL: Recording requests and responses header、body And metadata
Of course, there are other things besides logs , The following is presented in the form of a table :
| type | effect | explain |
|---|---|---|
| feign.Logger.Level | Modify log level | Contains four different levels :NONE、BASIC、HEADERS、FULL |
| feign.codec.Decoder | The parser that responds to the result | http Analyze the result of remote call , For example, parsing json String is java object |
| feign.codec.Encoder | Request parameter encoding | Encode the request parameters , Easy to pass http Request to send |
| feign. Contract | Supported annotation formats | The default is SpringMVC Annotations |
| feign. Retryer | Failure retry mechanism | Retry mechanism for request failure , The default is No , However, it will be used Ribbon Retry |
In general , The default value can meet our use , If you want to customize , Just create a custom @Bean Override default Bean that will do .
The configuration file
Modify based on the configuration file feign The log level can be for a single service :
feign: client: config: userservice: # Configuration for a microservice loggerLevel: FULL # The level of logging It can also be for all services :
feign: client: config: default: # Here we use default Global configuration , If you write the service name , It is the configuration for a micro service loggerLevel: FULL # The level of logging There are four levels of logs :
- NONE: No log information is recorded , This is the default .
- BASIC: Record only the requested method ,URL And the response status code and execution time
- HEADERS: stay BASIC On the basis of , Additionally, the request and response header information is recorded
- FULL: Record details of all requests and responses , Including header information 、 Request body 、 Metadata .

边栏推荐
- Redis 官方可视化工具,高颜值,功能真心强大!
- Webassembly 01 basic information
- kubernetes install completed
- High frequency electronic circuit review examination questions and answers
- 517. Super washing machine
- Three implementation methods of thread and the usage of handler
- C language explanation series -- understanding of functions (3) formal parameters, arguments, nested calls and chain access
- If MySQL calculates the current month change / current month increase / year-on-year change / year-on-year increase?
- Mongondb API usage
- flex布局原理及常见的父项元素
猜你喜欢
C language explanation series - understanding of functions (4) declaration and definition of functions, simple exercises

代码审计之百家cms

How students apply for free idea

SSTI-payload和各种绕过方法

Common modules in ansible

OD-Paper【2】:Fast R-CNN

Three implementation methods of thread and the usage of handler

NetCore MySql The user specified as a definer (‘admin‘@‘%‘) does not exist

Use flutter to adjust a color filter for the picture of my little sister

10. Regular expression matching
随机推荐
数仓搭建-DIM层
如何查看Pod里容器名称
Do you really understand fiddler, a necessary tool for testing?
攻防世界-FlatScience
FPGA question brushing sequence detection
Basic methods of realizing licensing function in C language
Development to testing: a six-year road to automation from scratch
[personal summary] end of July 24, 2022
Debugging sharp weapon! A lightweight log library log.c
The first positive number missing in question 41 of C language. Two methods, preprocessing, fast sorting and in situ hashing
Redis 官方可视化工具,高颜值,功能真心强大!
No EGL display error resolution
FTP实验及概述
Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
【个人总结】2022.7.24周结
《MongoDB入门教程》第08篇 比较运算符
Lesson 2 getting to know slam for the first time
Getaverse, a distant bridge to Web3
Chinese character style transfer --- learn the conversion and generation of one to many programmed Chinese characters through generation confrontation network
LNMP architecture