Is there any possibility to change the source name of NLog.config dynamically if yes can any one please help me.
<targets>
<target xsi:type="EventLog" name="eventlog" layout="${callsite}:${message}" log="Application" **source="MyAwesomeSolution"**/>
this is the source name which i wanna change with parameters coming from other method to NLog.Config file. source="MyAwesomeSolution"
Thanks in advance.
Santiago Trujillo
You can use any predefined variable or your custom field in the source field.
e.g. source="${event-properties:item=customName}"
and in your code, you can fill this value
logger.Info("this event is coming from may {customName}", "my app");
or you can use
logger.SetProperty("customName", "my app");
or even
logger.WithProperty("customName", "my app").Info("test message");
for more details check out the documentation
https://github.com/NLog/NLog/wiki/EventProperties-Layout-Renderer#example