Descriptive Logging in C#
Following a previous post on how I decide when to use which logging level . I recently wrote an extension class for the Microsoft.Extensions.Logging.ILogger in dotnet core.
This should be able to port easily to any language or framework.
https://gist.github.com/HaanstootZA/075d902ed6c42434ac2a017f217d72f3
This should be able to port easily to any language or framework.
Unit Of Work
Log a unit of work, this denotes a single step within the current process and should be have an associated unit test
Thread Sensitive
Log a thread sensitive unit of work
Breakpoint
If you reach any place within the code where you would like to add a breakpoint then log it accordingly.
Behavior
Log the expected behavior of a specific piece of code and should an associated behavior test.
Failure
Write a log entry for a piece of code that didn't return run as expected, but doesn't disrupt the proper execution of the program
Resolve
If you want to log unexpected behavior in the code that will need to be resolved.
Crash
There was a unrecoverable error within the code.
Code
The above code can be found athttps://gist.github.com/HaanstootZA/075d902ed6c42434ac2a017f217d72f3
Comments
Post a Comment