I occasionally get asked for this, so I’m going to post it here for
people to find. This is how to put an exception from a .Net
application into a custom log in the event viewer.
Let’s say you catch in exception in your code and you want to put it in the event logs. It’s a piece of cake.
Here is the C# code to do the same thing:
To test this, just creating the following code in a method somewhere:
Where ThrowException does nothing but throws an exception
And you get a nice little entry into your event viewer (I ran it twice, that is why you see 2 entries):
This entry was posted in .Net Development
. Bookmark the permalink
. Follow any comments here with the RSS feed for this post