输出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服务上加以下注解: