I am developing a web application in ASP.net that requires a username and password.
I want to register the IP address and machine name of the client that access this web application.
I am using log4net for logging.
I tried this piece of code, but I get the HostName Machine Machine in the log after deploying this web application using IIS-7 instead of Client Machine Name.
Login Page Page_Load Method:
protected void Page_Load(object sender, EventArgs e)
{
log4net.GlobalContext.Properties["Hostname"] = Dns.GetHostName();
}
Changes in Web.Config:
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %property{Hostname} [%thread] %-5level %logger - %message%newline" />
</layout>
Its a really huge project, so please offer me a method that requires minimal changes in the code to register the IP address and name of the Client's machine.
source
share