Fegin 请求日志查看配置
来源:互联网 发布:上海灵娱网络 编辑:程序博客网 时间:2024/06/06 11:42
在spring cloud的项目中,使用Fegin做多个服务之间的调用,是很常见的事情,但是调用失败后虽然能进入熔断器中,但是具体的失败原因,或者日志,如果能看到,那么对开发调试,将会有很大的帮助。
步骤
1、配置FeignConfig
@Configurationpublic class FeignConfig { /** * 配置请求重试 * */ @Bean public Retryer feignRetryer() { return new Retryer.Default(200, SECONDS.toMillis(2), 10); } /** * 设置请求超时时间 *默认 * public Options() { * this(10 * 1000, 60 * 1000); * } * */ @Bean Request.Options feignOptions() { return new Request.Options(60 * 1000, 60 * 1000); } /** * 打印请求日志 * @return */ @Bean public feign.Logger.Level multipartLoggerLevel() { return feign.Logger.Level.FULL; }}
2、配置 FeignClient
@FeignClient(value = "test-service", fallback = TestServiceHystrix.class, configuration = FeignConfig.class)public interface TestServiceClient { @PostMapping( value = "/upload",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},consumes = MediaType.MULTIPART_FORM_DATA_VALUE) UpLoadResult upload(@RequestParam("upload") MultipartFile file);}
3、请求接口,查看控制台日志
2017-10-09 19:31:01.438 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] ---> POST http://test-service/upload?upload=org.springframework.mock.web.MockMultipartFile%4021d2b412 HTTP/1.12017-10-09 19:31:01.438 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] Accept: application/json;charset=UTF-82017-10-09 19:31:01.439 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] Content-Type: multipart/form-data2017-10-09 19:31:01.439 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] ---> END HTTP (0-byte body)[test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@45a92394: startup date [Mon Oct 09 19:31:01 CST 2017]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@64b3b1ce2017-10-09 19:31:01.533 INFO [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring2017-10-09 19:31:01.776 INFO [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.netflix.config.ChainedDynamicProperty : Flipping property: test-test-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 21474836472017-10-09 19:31:01.819 INFO [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.n.u.concurrent.ShutdownEnabledTimer : Shutdown hook installed for: NFLoadBalancer-PingTimer-test-test-service2017-10-09 19:31:01.824 INFO [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.netflix.loadbalancer.BaseLoadBalancer : Client: test-test-service instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=test-test-service,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null2017-10-09 19:31:01.830 INFO [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.n.l.DynamicServerListLoadBalancer : Using serverListUpdater PollingServerListUpdater2017-10-09 19:31:01.851 INFO [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.netflix.config.ChainedDynamicProperty : Flipping property: test-test-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 21474836472017-10-09 19:31:01.852 INFO [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client test-test-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=test-test-service,current list of Servers=[10.10.0.176:8771],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;]},Server stats: [[Server:10.20.0.176:8700; Zone:defaultZone; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 08:00:00 CST 1970; First connection made: Thu Jan 01 08:00:00 CST 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0]]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@15044fde2017-10-09 19:31:02.047 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] <--- HTTP/1.1 500 (607ms)2017-10-09 19:31:02.047 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] cache-control: no-cache, no-store, max-age=0, must-revalidate2017-10-09 19:31:02.047 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] connection: close2017-10-09 19:31:02.047 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] content-type: application/json;charset=UTF-82017-10-09 19:31:02.047 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] date: Mon, 09 Oct 2017 11:31:07 GMT2017-10-09 19:31:02.047 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] expires: 02017-10-09 19:31:02.048 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] pragma: no-cache2017-10-09 19:31:02.048 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] transfer-encoding: chunked2017-10-09 19:31:02.048 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] x-application-context: test-test-service:dev:87712017-10-09 19:31:02.048 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] x-content-type-options: nosniff2017-10-09 19:31:02.048 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] x-frame-options: DENY2017-10-09 19:31:02.048 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] x-xss-protection: 1; mode=block2017-10-09 19:31:02.048 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] 2017-10-09 19:31:02.049 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] { "code" : 500, "error" : "Internal Server Error", "data" : null}2017-10-09 19:31:02.049 DEBUG [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.test.client.testServiceClient : [testServiceClient#upload] <--- END HTTP (72-byte body)2017-10-09 19:31:02.061 INFO [test-sys-test-service,e2818797113202e3,e2818797113202e3,true] 12972 --- [nio-8773-exec-2] c.x.t.c.hystrix.PlUserServiceHystrix : ---upload hystrix---
从我的日志中可以看到,这次请求失败了,并且能看到发出的请求url,方法类型,返回数据,负载均衡信息,请求的具体的集群ip等,这对我们调试有很大的帮助
关键设置
@Bean public feign.Logger.Level multipartLoggerLevel() { return feign.Logger.Level.FULL; }//-----------------------------------configuration = FeignConfig.class
我的官网http://guan2ye.com
我的CSDN地址http://blog.csdn.net/chenjianandiyi
我的简书地址http://www.jianshu.com/u/9b5d1921ce34
我的githubhttps://github.com/javanan
我的码云地址https://gitee.com/jamen/
阅读全文
0 0
- Fegin 请求日志查看配置
- nginx查看post请求日志
- MYsql日志配置及查看
- 查看 postfix配置错误信息日志
- Mysql 日志配置及查看
- SecureCrt 配置脚本查看日志
- Jetty 9.2请求访问日志配置
- 配置、error日志和请求上下文
- Linux 配置 tlog 命令 查看tomcat 日志
- nginx配置,重启,日志查看
- 查看MySQL4种日志参数及配置
- 查看变更请求明细日志状态的步骤
- 【LoadRunner】查看脚本请求日志和服务器返回值方法
- 查看LoadRunner脚本请求日志和服务器返回值方法
- MySQL日志——配置与查看二进制日志
- Fegin 多媒体上传调用
- 查看日志
- 查看日志
- GitHub 版本控制 项目托管 06 创建GitHub本地仓库2-加入代码工程
- 算法详解之MD5...
- 第四周项目2-单链表算法库
- Spring-boot中使用fastjson作为json框架
- Gemini Blueprint参考文档 第8章 打包和部署基于Spring的OSGi应用
- Fegin 请求日志查看配置
- 链表的高级特性
- 每个程序员都该知道的5个定律
- PHP smarty
- RxJava详解
- MySQL数据库安装与配置详解
- SSM(Spring+SpringMVC+Mybatis)框架整合配置方法
- C语言重解经典回溯算法案例-迷宫问题
- discuz论坛几种安全策略(一)