'What is the similar alternative for VB App.StartLogging and App.LogEvent in .Net C#?

I have to implement equivalent code of Visual Basic "App.StartLogging" and "App.LogEvent" in .NET C#. App.StartLogging has the two parameters i.e. logTarget and logMode.
(https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-basic-6/aa267165(v=vs.60))

I tried to find out same type of logging event in C#, but unfortunately not able to get. System. On some website, found like System.Diagnostics.EventLog is the alternate of App.StartLogging. But not getting how ? App.StartLogging help to log data in local file, but i didn't get same behavior in System.Diagnostics.EventLog.

Can you please help me to solve my issue ?



Solution 1:[1]

There is no direct replacement, see https://www.vbmigration.com/resources/detmigratingfromvb6.aspx?Id=19,

A few App members are used to log application events - namely the LogMode and LogPath properties and the StartLogging and LogEvent methods. These members have no direct counterparts in the .NET Framework.

You will other have to write your equivalents, or pick a 3rd party logging tool that can do what you need.

For instance, nLog will allow you to log to both the file system and to the Event Viewer. Logging an event is simple you simply write to the log, the StartLogging event is going to be harder, I don’t know of any logging framework or library that creates an event for that, typically it starts before everything else.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1