Skip to content

Commit f6071aa

Browse files
committed
format logging
1 parent 8b13d95 commit f6071aa

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/Api/Xero.Demo.Infrastructure/Extensions/AddMiddleWareExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public static void AddServices(this IServiceCollection services, IConfiguration
2121
{
2222
options.UseSqlite(Configuration.GetConnectionString(CONSTANTS.SqlLite))
2323
.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
24-
.EnableSensitiveDataLogging()
25-
.EnableDetailedErrors()
26-
.LogTo(Console.WriteLine)
24+
//.EnableSensitiveDataLogging()
25+
//.EnableDetailedErrors()
26+
//.LogTo(Console.WriteLine)
2727
;
2828
});
2929

src/Api/Xero.Demo.Infrastructure/Extensions/RequestResponseLoggingMiddleware.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ private async Task LogRequest(HttpContext context)
3232
await using var requestStream = _recyclableMemoryStreamManager.GetStream();
3333
await context.Request.Body.CopyToAsync(requestStream);
3434
_logger.LogInformation($"Http Request Information:{Environment.NewLine}" +
35-
$"Schema:{context.Request.Scheme} " +
36-
$"Host: {context.Request.Host} " +
37-
$"Path: {context.Request.Path} " +
38-
$"QueryString: {context.Request.QueryString} " +
35+
$"Schema:{context.Request.Scheme} {Environment.NewLine}" +
36+
$"Host: {context.Request.Host} {Environment.NewLine}" +
37+
$"Path: {context.Request.Path} {Environment.NewLine}" +
38+
$"QueryString: {context.Request.QueryString} {Environment.NewLine}" +
3939
$"Request Body: {ReadStreamInChunks(requestStream)}");
4040
context.Request.Body.Position = 0;
4141
}
@@ -72,10 +72,11 @@ private async Task LogResponse(HttpContext context)
7272
context.Response.Body.Seek(0, SeekOrigin.Begin);
7373

7474
_logger.LogInformation($"Http Response Information:{Environment.NewLine}" +
75-
$"Schema:{context.Request.Scheme} " +
76-
$"Host: {context.Request.Host} " +
77-
$"Path: {context.Request.Path} " +
78-
$"QueryString: {context.Request.QueryString} " +
75+
$"Schema:{context.Request.Scheme} {Environment.NewLine}" +
76+
$"Host: {context.Request.Host} {Environment.NewLine}" +
77+
$"Path: {context.Request.Path} {Environment.NewLine}" +
78+
$"QueryString: {context.Request.QueryString} {Environment.NewLine}" +
79+
$"StatusCode: {context.Response?.StatusCode} {Environment.NewLine}" +
7980
$"Response Body: {text}");
8081

8182
await responseBody.CopyToAsync(originalBodyStream);

0 commit comments

Comments
 (0)