Writing plain text to a RollingFile sink and happened to output a line of JSON. It seems to convert closing brace triplets to the double curly braces. The code below should illustrate it. testLogger is a simple wrapper I use to let me optionally send it to the debug window instead of the file. The results are from the file.
var json1 = @"{ ""test"": ""test""}";
testLogger.Log(json1);
var json2 = @"{ ""test"": ""test"", { ""nest1"": ""one"" }}";
testLogger.Log(json2);
var json3 = @"{ ""test"": ""test"", { ""nest1"": ""one"", { ""nest2"": ""two""}}}";
testLogger.Log(json3);
2016-10-17 08:34:48.111 -04:00 [Warning] { "test": "test"}
2016-10-17 08:34:48.111 -04:00 [Warning] { "test": "test", { "nest1": "one" }}
2016-10-17 08:34:48.111 -04:00 [Warning] { "test": "test", { "nest1": "one", { "nest2": "two"}}
Hi, thanks for the report!
This is because the argument to the logger is a message template (format string), not the actual data to log.
You can get the output you want with:
var json1 = @"{ ""test"": ""test""}";
testLogger.Log("{Json:l}", json1);
(The :l
will write the string as a literal, with no additional quotes.)
Cheers,
Nick
Gosh that was awfully quick. Many thanks.
You're welcome, thanks 👍
Most helpful comment
Hi, thanks for the report!
This is because the argument to the logger is a message template (format string), not the actual data to log.
You can get the output you want with:
(The
:l
will write the string as a literal, with no additional quotes.)Cheers,
Nick