Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Commit 5543d29

Browse files
committed
Merge branch 'release/2.2' => 'master'
2 parents c3d0767 + 795a223 commit 5543d29

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Microsoft.AspNetCore.Hosting/Internal/HostingLoggerExtensions.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public static void ServerShutdownException(this ILogger logger, Exception ex)
9494

9595
private class HostingLogScope : IReadOnlyList<KeyValuePair<string, object>>
9696
{
97-
private readonly HttpContext _httpContext;
97+
private readonly string _path;
98+
private readonly string _traceIdentifier;
9899
private readonly string _correlationId;
99100

100101
private string _cachedToString;
@@ -113,11 +114,11 @@ public KeyValuePair<string, object> this[int index]
113114
{
114115
if (index == 0)
115116
{
116-
return new KeyValuePair<string, object>("RequestId", _httpContext.TraceIdentifier);
117+
return new KeyValuePair<string, object>("RequestId", _traceIdentifier);
117118
}
118119
else if (index == 1)
119120
{
120-
return new KeyValuePair<string, object>("RequestPath", _httpContext.Request.Path.ToString());
121+
return new KeyValuePair<string, object>("RequestPath", _path);
121122
}
122123
else if (index == 2)
123124
{
@@ -130,7 +131,8 @@ public KeyValuePair<string, object> this[int index]
130131

131132
public HostingLogScope(HttpContext httpContext, string correlationId)
132133
{
133-
_httpContext = httpContext;
134+
_traceIdentifier = httpContext.TraceIdentifier;
135+
_path = httpContext.Request.Path.ToString();
134136
_correlationId = correlationId;
135137
}
136138

@@ -141,8 +143,8 @@ public override string ToString()
141143
_cachedToString = string.Format(
142144
CultureInfo.InvariantCulture,
143145
"RequestId:{0} RequestPath:{1}",
144-
_httpContext.TraceIdentifier,
145-
_httpContext.Request.Path);
146+
_traceIdentifier,
147+
_path);
146148
}
147149

148150
return _cachedToString;

0 commit comments

Comments
 (0)