Priority vs. Severity(TraceEventType)

Topics: Logging Application Block
Feb 1, 2007 at 1:48 PM

I'm trying to figure out what would be the best way to use the logging application block.

One of the questions I'm stuck right now is whether one should use the "Priority" or the "Severity"(TraceEventType) attributes while logging. Or maybe both for different purposes? What is here the best practice?

Looking into the documentation, API and samples I'm getting the impression that using Priority fields is the more preferred way to narrow valid log entries. So there is already a Priority-Filter class given.
On the other side the categorySources allow to define the SourceLevel(TraceEventType) at which logs to this category are accepted. The TraceEventType is also used heavily in the Standard .Net Logging/Tracing classes (System.Diagnostic namespace).

I would appreciate every advice and hint.

Feb 2, 2007 at 1:58 AM
I don't know if there is a best practice. I think it depends on your needs.

The main differences are:

1) Priority is an integer and can thus take on more values than Severity.
2) Priority filtering is across all categories whereas Severity filtering is particular to a category.
3) You can use PriorityFilter.ShouldLog to save from having to create a log entry for a bit more speed.

In general you have more flexibility with Priority than you do with Severity.




David Hayden
Microsoft MVP C#