IP Address

4 messages Options
Embed this post
Permalink
Brad

IP Address

Reply Threaded More More options
Print post
Permalink
Is it possible for NLog, when used in a web application, to log the client's IP address (i.e. does it have a layout renderer for that)?  I'm guessing this should be trivial, and probably uses "${aspnet-request}", but the documentation I can find is insufficient for me to figure out how to do it.

I realize I could do this within my messages using "Request.UserHostAddress", but I'd like to set this up in my config file and populate a specific field with it, rather than making it a part of a longer message that I would then need to parse out.

Thanks!
Brad.
Jason LaFlair

Re: IP Address

Reply Threaded More More options
Print post
Permalink
based on: http://nlog-project.org/lr.aspnet-request.html

if you use the layour renderer ${aspnet-request:serverVariable=remote_host} you should get what you are looking for.
Jason LaFlair

Re: IP Address

Reply Threaded More More options
Print post
Permalink
or ${aspnet-request:serverVariable=remote_addr}
Brad

Re: IP Address

Reply Threaded More More options
Print post
Permalink
Thanks!  That was just what I needed.  :-)

Brad.