How to write error log or exception into file in C#.NET
<p>I need help in writing error into separate text file and Email that file to me. Actually, I had created windows application but I didn't add any exception or writing error into separate file. Now, I want whenever my application is interrupted because of any error then error should be noted into separate text file and that file should be email to me. </p>

<p>I did research on error log file and all I found that create separate Class for writing Error Log into text file and call that file into try-catch block of all the methods. But my program/application has grown vast and I need to add intermediate of it. Also, I found about log4net but still it works in same manner. </p>

<p>Can anyone guide me how to write error log at application level or when application get any error message?</p>

<p>Thanks for help.</p>
