Is it possible to use "variables" in the NLog.config
configuration file to get values from some C# code ?
The reason I want to use a "variable" is to retrieve the password (that I use to log info in my database) previously entered by the user in a windows form.
I found the answer:
I need to use the Global Diagnostics Context class, like that:
GlobalDiagnosticsContext.Set("myVariableName", "myValue");
${gdc:item=myVariableName}
gives me "myValue"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With