From 53e5c3d56c1257260dd01aa37987860eca621649 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 28 Nov 2016 15:24:30 -0800 Subject: [PATCH] #1001 don't log stack traces for localhost bind failures. --- .../KestrelServer.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs b/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs index e7e4e38d62..57fbc17017 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServer.cs @@ -150,14 +150,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel } catch (AggregateException ex) when (ex.InnerException is UvException) { - if ((ex.InnerException as UvException).StatusCode == Constants.EADDRINUSE) + var uvEx = (UvException)ex.InnerException; + if (uvEx.StatusCode == Constants.EADDRINUSE) { throw new IOException($"Failed to bind to address {parsedAddress.ToString()} on the IPv4 loopback interface: port already in use.", ex); } else { - _logger.LogWarning(0, ex, $"Unable to bind to {parsedAddress.ToString()} on the IPv4 loopback interface."); - exceptions.Add(ex.InnerException); + _logger.LogWarning(0, $"Unable to bind to {parsedAddress.ToString()} on the IPv4 loopback interface: ({uvEx.Message})"); + exceptions.Add(uvEx); } } @@ -169,14 +170,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel } catch (AggregateException ex) when (ex.InnerException is UvException) { - if ((ex.InnerException as UvException).StatusCode == Constants.EADDRINUSE) + var uvEx = (UvException)ex.InnerException; + if (uvEx.StatusCode == Constants.EADDRINUSE) { throw new IOException($"Failed to bind to address {parsedAddress.ToString()} on the IPv6 loopback interface: port already in use.", ex); } else { - _logger.LogWarning(0, ex, $"Unable to bind to {parsedAddress.ToString()} on the IPv6 loopback interface."); - exceptions.Add(ex.InnerException); + _logger.LogWarning(0, $"Unable to bind to {parsedAddress.ToString()} on the IPv6 loopback interface: ({uvEx.Message})"); + exceptions.Add(uvEx); } }