DUBBO-438 ExceptionFilter在服务器端打印日志时显示客户端的IP

This commit is contained in:
kimi 2012-06-25 10:40:45 +08:00
parent 83b69b7951
commit ca1d764ede
1 changed files with 3 additions and 2 deletions

View File

@ -27,6 +27,7 @@ import com.alibaba.dubbo.rpc.Filter;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Result;
import com.alibaba.dubbo.rpc.RpcContext;
import com.alibaba.dubbo.rpc.RpcException;
import com.alibaba.dubbo.rpc.RpcResult;
import com.alibaba.dubbo.rpc.service.GenericService;
@ -72,7 +73,7 @@ public class ExceptionFilter implements Filter {
return result;
}
// 未在方法签名上定义的异常在服务器端打印ERROR日志
logger.error("Got unchecked and undeclared exception. service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + exception.getClass().getName() + ": " + exception.getMessage(), exception);
logger.error("Got unchecked and undeclared exception which called by " + RpcContext.getContext().getRemoteHost() + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + exception.getClass().getName() + ": " + exception.getMessage(), exception);
// 异常类和接口类在同一jar包里直接抛出
String serviceFile = ReflectUtils.getCodeBase(invoker.getInterface());
String exceptionFile = ReflectUtils.getCodeBase(exception.getClass());
@ -97,7 +98,7 @@ public class ExceptionFilter implements Filter {
}
return result;
} catch (RuntimeException e) {
logger.error("Got unchecked and undeclared exception. service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e);
logger.error("Got unchecked and undeclared exception which called by " + RpcContext.getContext().getRemoteHost() + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e);
throw e;
}
}