When an exception is thrown, we log it. However, we are unable to retrieve the server name or I.P address. Not sure if this is the right way to retrieve it.
Log.ServerName = HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"];
Log.ServerIP = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
This doesn’t seem to work. It returns ‘localhost’ and ::1 as the I.P address.
Based on your comment seems like you want to log the local server name and ip address. One solution is to use Dns.GetHostName and Dns.GetHostAddresses.