fix
parent
8a2133a2d3
commit
5dc9919263
|
@ -7,6 +7,7 @@
|
||||||
<RepositoryUrl>https://dev.azure.com/tstanciu94/_git/NDB</RepositoryUrl>
|
<RepositoryUrl>https://dev.azure.com/tstanciu94/_git/NDB</RepositoryUrl>
|
||||||
<PackageReleaseNotes>.NET standard library for logging stuff in an API.</PackageReleaseNotes>
|
<PackageReleaseNotes>.NET standard library for logging stuff in an API.</PackageReleaseNotes>
|
||||||
<PackageTags>NDB NDB.Logging</PackageTags>
|
<PackageTags>NDB NDB.Logging</PackageTags>
|
||||||
|
<Version>1.0.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Microsoft.AspNetCore.Http.Internal;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
@ -25,7 +25,7 @@ namespace NDB.Logging.Api
|
||||||
stopWatch.Start();
|
stopWatch.Start();
|
||||||
|
|
||||||
var uid = Guid.NewGuid();
|
var uid = Guid.NewGuid();
|
||||||
var request = ((DefaultHttpRequest)((ControllerBase)context.Controller).Request);
|
var request = (HttpRequest)((ControllerBase)context.Controller).Request;
|
||||||
var requestUrl = request.Path;
|
var requestUrl = request.Path;
|
||||||
|
|
||||||
if (request.QueryString != null && request.QueryString.HasValue)
|
if (request.QueryString != null && request.QueryString.HasValue)
|
||||||
|
@ -51,12 +51,13 @@ namespace NDB.Logging.Api
|
||||||
_logger.LogDebug($"Request {uid} duration: {stopWatch.ElapsedMilliseconds:N0} ms");
|
_logger.LogDebug($"Request {uid} duration: {stopWatch.ElapsedMilliseconds:N0} ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> GetRequestBody(DefaultHttpRequest request)
|
private async Task<string> GetRequestBody(HttpRequest request)
|
||||||
{
|
{
|
||||||
if (request.ContentLength == 0)
|
if (request.ContentLength == 0)
|
||||||
return "-";
|
return "-";
|
||||||
|
|
||||||
var body = new StreamReader(request.Body);
|
using (var body = new StreamReader(request.Body))
|
||||||
|
{
|
||||||
body.BaseStream.Seek(0, SeekOrigin.Begin);
|
body.BaseStream.Seek(0, SeekOrigin.Begin);
|
||||||
var bodyStr = await body.ReadToEndAsync();
|
var bodyStr = await body.ReadToEndAsync();
|
||||||
|
|
||||||
|
@ -64,3 +65,4 @@ namespace NDB.Logging.Api
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue