A New Pattern for Exception Logging

added by DotNetKicks
6/11/2020 2:33:43 PM

629 Views

Your code should log exceptions from within an exception filter, not a catch block. The old pattern of "log-and-propagate" looks like this: The logging should be moved into an exception filter like this: Similarly, the old pattern of "log-and-handle" looks something like this: The logging should be moved into an exception filter like this: Both of these examples assume the presence of a couple simple utility methods: The remainder of this blog post goes into the "why" behind the new pattern.


0 comments