Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The solution is a log file that will keep track of loops in your code, and automatically delete the log entries for each successful iteration of that loop. This way, you can maintain a highly detained log file which remains relatively small at the same time. When your service breaks, your log file will tell you exactly where it happened, plus all the necessary context to explain how and why it happened.</p> <p>You can download this logfile generator from <a href="http://sourceforge.net/projects/smartl/files/?source=navbar" rel="nofollow">http://sourceforge.net/projects/smartl/files/?source=navbar</a>. It's a stand alone class and all its methods is static. An example class is provided to show you how to use the logging methods correctly:</p> <pre><code>public void ExampleMethod() { SmartLog.EnterMethod("ExampleMethod()"); try { SmartLog.Write("Some code happening before the loop"); Guid exampleLoopID = SmartLog.RegisterLoop("exampleLoopID"); for (int i = 0; i &lt; 10; i++) { SmartLog.IncrementLoop(exampleLoopID); SmartLog.Write("Some code happening inside the loop."); } SmartLog.CompleteLoop(exampleLoopID); SmartLog.Write("Some code happening after the loop."); SmartLog.LeaveMethod("ExampleMethod()"); } catch (Exception ex) { SmartLog.WriteException(ex); SmartLog.LeaveMethod("ExampleMethod()"); throw; } } </code></pre> <p>Make sure your application has read and write access on its root folder.</p> <p>If you execute the code, and you break it inside the loop, the logfile will look something like this:</p> <pre><code>. ENTER METHOD: FirstMethod() some code happening here. Calling a different method: . . ENTER METHOD: ExampleMethod() some code happening before the loop. LOOP: doWorkLoopID [4135a8ed-05b7-45de-b887-b2ab3c638faa] - CURRENT ITERATION: 20 some code happening inside the loop. </code></pre> <p>Once the loop has been completed, its content is removed, and your log file will look like this:</p> <pre><code>. ENTER METHOD: FirstMethod() some code happening here. Calling a different method: . . ENTER METHOD: ExampleMethod() some code happening before the loop. LOOP: doWorkLoopID [4135a8ed-05b7-45de-b887-b2ab3c638faa] - TOTAL ITERATIONS: 22 some code happening after the loop. . . LEAVING METHOD: ExampleMethod() some code happening here. some code happening here. . LEAVING METHOD: FirstMethod() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload