Reputation: 102
I have a asp.net web service application (asmx). NLog has been configured on the project. I want to add the caller's ip address in the logfile. I need to access the REMOTE_ADDR property from within the nlog config file. This is what I tried.
<target name="file" xsi:type="File"
layout="${longdate} ${logger} ${callsite} ${asp-request:item=REMOTE_ADDR} ${message}"
fileName="${basedir}/logs/${shortdate}.log" />
the renderer ${asp-request:item=REMOTE_ADDR} should have done the trick. But nothing happens. What am I missing?
Note : I have added reference to the NLog.Extended.dll to the project.
Any help would be appreciated, please.
Upvotes: 0
Views: 2052
Reputation: 1
As a side note using:
${ aspnet-request:serverVariable = remote_addr }
Produced the following error:
LayoutRenderer cannot be found: 'aspnet-request'
You have to install NLog.Web to make this work.
Upvotes: 0
Reputation: 1145
You've probably worked it out by now, but the code you were looking for is:
${aspnet-request:serverVariable=remote_addr}
Upvotes: 2