Instrumentation in C# / .NET
For many programmers a try/catch with stack trace it is enough
try { var p = new Person(); p.DateOfBirth = DateTime.Now.AddYears(-10); p.Drink(10, 2); } catch (Exception ex) { Console.WriteLine("ERROR OCCURED " + ex.StackTrace); }
Others want to see also functions arguments, like in
p.Drink(10, 2);
will produce the result
ERROR An exception occured in method InstrumentationPostSharp.Person.Drink with (beersNumber = 10 , vodkaNumber = 2)
For this you can install the package
https://www.nuget.org/packages/LoggerAspect.Nlog
that have full source code at
https://github.com/vnvizitiu/AOP/tree/master/PostSharpTutorial
and watch my video for more details
https://youtu.be/qe2kpuuWXkw
Leave a Reply