输出dubbo信息日志

2022-06-18 08:56:15

输出dubbo信息日志

第一步

import lombok.extern.slf4j.Slf4j;import org.apache.dubbo.rpc.*;

@Slf4jpublicclassDubboServiceLogFilterimplementsFilter{

    @Overridepublic Resultinvoke(Invoker<?> invoker, Invocation invocation) throws RpcException{
        Long startTime= System.currentTimeMillis();
        Result result= invoker.invoke(invocation);
        Long endTime= System.currentTimeMillis();
        Long times= endTime- startTime;
        Object[] arguments= invocation.getArguments();

        log.info("远程调用dubbo服务名称:{}, 执行时间:{} ms, 调用dubbo方法:{},请求参数:{}, 返回值:{}",
                invoker.getInterface().getName(), times, invocation.getMethodName(), arguments, result.getValue());return result;}}

第二步

在这里插入图片描述在resource下面创建一个文件org.apache.dubbo.rpc.Filter,里面内容为过滤器的那个类的路径

在这里插入图片描述

在需要使用的dubbo服务上加以下注解:
在这里插入图片描述

  • 作者:zxl8899
  • 原文链接:https://blog.csdn.net/zxl8899/article/details/107400915
    更新时间:2022-06-18 08:56:15