5
5
using System . Collections ;
6
6
using System . Collections . Generic ;
7
7
using System . Diagnostics ;
8
+ using System . Globalization ;
8
9
using Microsoft . AspNetCore . Http ;
9
10
using Microsoft . Extensions . Logging ;
10
11
@@ -126,7 +127,11 @@ public override string ToString()
126
127
{
127
128
if ( _cachedToString == null )
128
129
{
129
- _cachedToString = $ "RequestId:{ _httpContext . TraceIdentifier } RequestPath:{ _httpContext . Request . Path } ";
130
+ _cachedToString = string . Format (
131
+ CultureInfo . InvariantCulture ,
132
+ "RequestId:{0} RequestPath:{1}" ,
133
+ _httpContext . TraceIdentifier ,
134
+ _httpContext . Request . Path ) ;
130
135
}
131
136
132
137
return _cachedToString ;
@@ -201,7 +206,18 @@ public override string ToString()
201
206
{
202
207
if ( _cachedToString == null )
203
208
{
204
- _cachedToString = $ "Request starting { _request . Protocol } { _request . Method } { _request . Scheme } ://{ _request . Host } { _request . PathBase } { _request . Path } { _request . QueryString } { _request . ContentType } { _request . ContentLength } ";
209
+ _cachedToString = string . Format (
210
+ CultureInfo . InvariantCulture ,
211
+ "Request starting {0} {1} {2}://{3}{4}{5}{6} {7} {8}" ,
212
+ _request . Protocol ,
213
+ _request . Method ,
214
+ _request . Scheme ,
215
+ _request . Host ,
216
+ _request . PathBase ,
217
+ _request . Path ,
218
+ _request . QueryString ,
219
+ _request . ContentType ,
220
+ _request . ContentLength ) ;
205
221
}
206
222
207
223
return _cachedToString ;
@@ -227,7 +243,7 @@ private class HostingRequestFinished : IReadOnlyList<KeyValuePair<string, object
227
243
228
244
private readonly HttpContext _httpContext ;
229
245
private readonly TimeSpan _elapsed ;
230
-
246
+
231
247
private string _cachedToString ;
232
248
233
249
public int Count
@@ -266,7 +282,12 @@ public override string ToString()
266
282
{
267
283
if ( _cachedToString == null )
268
284
{
269
- _cachedToString = $ "Request finished in { _elapsed . TotalMilliseconds } ms { _httpContext . Response . StatusCode } { _httpContext . Response . ContentType } ";
285
+ _cachedToString = string . Format (
286
+ CultureInfo . InvariantCulture ,
287
+ "Request finished in {0}ms {1} {2}" ,
288
+ _elapsed . TotalMilliseconds ,
289
+ _httpContext . Response . StatusCode ,
290
+ _httpContext . Response . ContentType ) ;
270
291
}
271
292
272
293
return _cachedToString ;
0 commit comments