.NET : How to set user information in an EventLog Entry?

后端 未结 3 1873
孤独总比滥情好
孤独总比滥情好 2020-12-11 20:33

The System.Diagnostics.EventLog class provides a way to interact with a windows event log. I use it all the time for simple logging...

System.Diagnostics.Ev         


        
3条回答
  •  醉酒成梦
    2020-12-11 21:30

    Usually, the user executing the code that calls the EventLog.WriteEntry method will be the user displayed in the event log for the entry.

    You could try impersonating another user by creating your own Principal and Identity and associating it with the current thread, however this is not advised as it could introduce security issues and will definitely complicate your application.

提交回复
热议问题