how to web service target URL dynamically in NLog for Xamarin.Forms in NLog.Config file. need to get a to a variable instead of hardcoding.
<target name="webservice"
xsi:type="WebService"
url="{var:url}"
protocol="JsonPost"
proxyType="NoProxy"
namespace="{var:namespace}"
methodName ="InsertLogs"
encoding="utf-8">
<parameter name="Datetime" type="System.String" layout="${time}"/>
<parameter name="level" layout="${level}" />
</target>
CodePudding user response:
You can load and modify your target at runtime and set the URL:
var target = LogManager.Configuration.FindTargetByName("webservice") as WebServiceTarget;
target.Url = new Uri("https://my.url/logs");
LogManager.ReconfigExistingLoggers();