Tip To Log

We often like to know what happens in a procedure and also we like to figure out if we see something in the log, where in the code it happened. Therefore it is handy to start and end each procedure with log. To do this we can put a small generic code like this

Trace.WriteLine("Beginning with " + System.Reflection.MethodInfo.GetCurrentMethod().Name);

it will work just fine

Author: Pouya Panahy

Microsoft certified DevOps engineer with passion in analysing, designing and implementing solutions for Azure Cloud with hands-on experience in security and quality assurence.

One thought on “Tip To Log”

  1. ///
    /// Logs the calling method when Verbose mode
    public static void Starting()
    if (!GeneralSwitch.TraceVerbose) return;
    var method = new System.Diagnostics.StackFrame(1).GetMethod();

    method.Name, "-"), "STARTING");

Leave a Reply