You can mark methods with the NonEventAttribute to prevent EventSource from including methods in the manifest:
[Event(3, Message = "Could not parse {0} file with name {1}", Level = EventLevel.Error)]
internal void FileParsingError(string fileType, string fileName, string exceptionMessage, string stackTrace)
{
WriteEvent(3, fileType, fileName);
}
[NonEvent]
internal void FileParsingError(string fileType, string fileName, Exception ex)
{
FileParsingError(fileType, fileName, ex.Message, ex.StackTrace);
}
Use like this:try
{
KraftvaerkEventSource.Log.StartedFileParsing("Example", "file2.csv");
throw new Exception("Some parsing error");
}
catch (Exception ex)
{
KraftvaerkEventSource.Log.FileParsingError("Example", "file2.csv", ex);
}
On a side note: I found this NonEvent attribute by decompiling the EventSource class and looking at the implementation of CreateManifest. Maybe you should include this feature in the developers guide, and include an example for EventSource on MSDN.