0

We are using Log4Net to handle application logging. One of the requirement is to log all events to Event Viewer of the Web Server that's running the application.

I am unable to find out how to log the following:

  1. User name (User using the application from remote).

  2. Computer (the computer from which the application is started by the user. Currently it show the Server on which the app is running.)

enter image description here Application runs in LAN only and user windows authentication.

Please help with a solution on how to add these details using the config file.

Navaneeth
  • 190
  • 1
  • 1
  • 16
  • That's not possible with log4net, as it uses the [EventLog.WriteEntry method](https://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.writeentry%28v=vs.110%29.aspx) to write to the event log, and neither of those properties can be set. (I believe that it is not possible to set the user or computer name at all on a log entry, but there doesn't seem to be [any certainty on the subject](http://serverfault.com/a/277484/1002)) – stuartd Jan 04 '16 at 14:02
  • Thanks stuartd, Is there any alternate approach to add these details in Event Viewer for each log entry that is made? – Navaneeth Jan 05 '16 at 08:49
  • No, they are for the Event Log itself, not for log entries. – stuartd Jan 05 '16 at 10:03
  • say a user user_123 is accessing the application MyApp from his workstation desk_123. MyApp is hosted on server_1. Is it possible to write any code in .Net to log in the Event Viewer of server_1 the details -> User as user_123 and Computer as desk_123? – Navaneeth Jan 06 '16 at 07:59
  • No it isn't possible. – stuartd Jan 06 '16 at 10:26

1 Answers1

-1

That's not possible with log4net and dotnetFramework API enter image description here

vin
  • 1