I want to log my server name in ASP.NET Application, I use multi-servers and load balancing so I need to log the server name.
But what is the difference between these ways to get the server name?
and which one is true or better to log?
any idea?
or any other ways?
System.Environment.MachineName
Server.MachineName
System.Net.Dns.GetHostName()
There is also another ways but not always return correct server name:
Request.ServerVariables["SERVER_NAME"]
System.Net.Dns.GetHostEntry(Request.ServerVariables("SERVER_NAME")).HostName
System.Net.Dns.GetHostEntry(Request.ServerVariables("LOCAL_ADDR")).HostName