显示微服务间feign调用的日志
第一步
package com.niuniu.common.config;
import com.niuniu.common.CommonConstant;
import com.niuniu.common.utils.UserContext;
import feign.Logger;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Bean;
public class DefaultFeignConfig {
@Bean
public Logger.Level feignLogLevel(){
return Logger.Level.FULL;
}
}
第二步调用方的application.yaml文件
logging:
level:
com.niuniu.user.feignclient.OrderClient: debug
测试结果:
package com.niuniu.user.feignclient;
import com.niuniu.common.config.DefaultFeignConfig;
import com.niuniu.user.model.Order;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@Component
@FeignClient(value = "order-service", configuration = DefaultFeignConfig.class)
public interface OrderClient {
@GetMapping(value = "/order-service/order/queryOrderByIds")
List<Order> queryOrderByIds(@RequestParam("ids") List<Long> ids);
}