My log4net object looks something like this (since I want to log my set as a json object)
_log.Debug(new JObject(new JProperty("Prop1", "Val1"),
new JProperty("Prop2", "Val2")).ToString());
For better code readability and easy adding of additional properties, I'd like to do something like this
Utility.WriteLog({"Prop1", "Val1"},
{"Prop2", "Val2"});
I am not sure how the WriteLog() method would look like other than that it should have a params argument considering that there will be a variable number of property/value pairs that need to be logged.
I have considered a dictionary (see below) and the WriteLog function would create a JsonObject with the property/value keys from the dictionary:
Utility.WriteLog(new Dictionary<string, string>()
{
{"Prop1", "Val1"},
{"Prop2", "Val2" }
});
Is this the best approach, or is there a more succinct alternative?