Log binary data as a parameter #2860

This commit is contained in:
Chris Ross (ASP.NET) 2018-10-22 14:51:29 -07:00
parent 2a610ee1b8
commit 32532078d6
2 changed files with 6 additions and 2 deletions

View File

@ -66,6 +66,7 @@ namespace SampleApp
var hostBuilder = new WebHostBuilder() var hostBuilder = new WebHostBuilder()
.ConfigureLogging((_, factory) => .ConfigureLogging((_, factory) =>
{ {
factory.SetMinimumLevel(LogLevel.Debug);
factory.AddConsole(); factory.AddConsole();
}) })
.ConfigureAppConfiguration((hostingContext, config) => .ConfigureAppConfiguration((hostingContext, config) =>

View File

@ -174,13 +174,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal
builder.Append(" "); builder.Append(" ");
} }
builder.AppendLine(); builder.AppendLine();
builder.Append("{0}");
var rawDataBuilder = new StringBuilder();
// Write the bytes as if they were ASCII // Write the bytes as if they were ASCII
for (int i = 0; i < buffer.Length; i++) for (int i = 0; i < buffer.Length; i++)
{ {
builder.Append((char)buffer[i]); rawDataBuilder.Append((char)buffer[i]);
} }
_logger.LogDebug(builder.ToString()); _logger.LogDebug(builder.ToString(), rawDataBuilder.ToString());
} }
// The below APM methods call the underlying Read/WriteAsync methods which will still be logged. // The below APM methods call the underlying Read/WriteAsync methods which will still be logged.