If I add a collection, dictionary, or an object to logger properties. They are not static, they are generated during production and can vary in content lenght.
var queryParams = request.QueryString.AllKeys.ToDictionary(k => k, k => request.QueryString[k]);
log4net.LogicalThreadContext.Properties["QueryParams"] = queryParams;
var testCollection = new List<string> { "one", "two", "three" };
log4net.LogicalThreadContext.Properties["ACollection"] = testCollection;
var obj = new { Prop1 = "value", Prop2 = 5 };
log4net.LogicalThreadContext.Properties["AObject"] = obj;
I want the output to look like this:
{
...
"QueryParams": {
"Param1": "value1",
"Param2": "value2",
},
"ACollection": [
"one",
"two",
"three"
],
"AObject": {
"Prop1": "value",
"Prop2": 5
}
...
}
How do I get log4net.Ext.Json to output them correctly?
Also, if null or empty I would like them to be left out, not shown as null or an empty collection.