Skip to content

Commit 41b8e2e

Browse files
authored
Log DebugException from RpcException if present (#1625)
1 parent f47ac6b commit 41b8e2e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Grpc.AspNetCore.Server/Internal/GrpcServerLog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ public static void ErrorExecutingServiceMethod(ILogger logger, string serviceMet
129129
_errorExecutingServiceMethod(logger, serviceMethod, ex);
130130
}
131131

132-
public static void RpcConnectionError(ILogger logger, StatusCode statusCode, string detail)
132+
public static void RpcConnectionError(ILogger logger, StatusCode statusCode, string detail, Exception? debugException)
133133
{
134-
_rpcConnectionError(logger, statusCode, detail, null);
134+
_rpcConnectionError(logger, statusCode, detail, debugException);
135135
}
136136

137137
public static void EncodingNotInAcceptEncoding(ILogger logger, string grpcEncoding)

src/Grpc.AspNetCore.Server/Internal/HttpContextServerCallContext.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ private void ProcessHandlerError(Exception ex, string method)
179179
if (ex is RpcException rpcException)
180180
{
181181
// RpcException is thrown by client code to modify the status returned from the server.
182-
// Log the status and detail. Don't log the exception to reduce log verbosity.
183-
GrpcServerLog.RpcConnectionError(Logger, rpcException.StatusCode, rpcException.Status.Detail);
182+
// Log the status, detail and debug exception (if present).
183+
// Don't log the RpcException itself to reduce log verbosity. All of its information is already captured.
184+
GrpcServerLog.RpcConnectionError(Logger, rpcException.StatusCode, rpcException.Status.Detail, rpcException.Status.DebugException);
184185

185186
// There are two sources of metadata entries on the server-side:
186187
// 1. serverCallContext.ResponseTrailers

0 commit comments

Comments
 (0)