I have an NLog variable that I want to set the value of at runtime, in C#:
LogManager.Configuration.Variables["MyVarName"] = DetermineMyVarValue();
But that's NLog code. I am considering using Common.Logging rather than directly using NLog. I do not see how to do this sort of thing through Common.Logging. Is there a way?
Alternatively, perhaps is there a way to do it at runtime from within the NLog config file itself? So that Common.Logging can be sidestepped? For example, something like:
<variable name="MyVarName" value="MyStaticClass.DetermineMyVarValue()"/>
Preferably where that function would be called once, upon first use, rather than being called every time the variable is referenced?
Haven't yet found a direct answer, but I have found something that's good enough for my purposes, so I'm mentioning it here in case it might help someone in the future:
Instead of a variable, I just wrote a custom layout renderer, which is pretty straightforward.