Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In a production environment I have logging set to "INFO" by default (using log4net), and at this level I log sufficient information to have a very good chance of diagnosing any errors. So what is "sufficient" information? Well, that all depends on your system. In our system I log the entry and exit points from the most important methods, including their input parameters and return values (unless this is a lot of data). I'm willing to accept an 5-10% overhead for logging (but you should measure this). </p> <p>My perferred format is like this:</p> <p>Method entry:</p> <p>->MyMethod(1, "arg1")</p> <p>Method exit:</p> <p>&lt;-MyMethod(1, "arg1") = true</p> <p>The arrows mean I can easily see whether this is entry or exit. By including the arguments and return value I get the most critical data for diagnosing errors. I only ever have one return point from my methods, so I do not have to worry about multiple exit points for my logging.</p> <p>By logging method entry/exit I find I do not have to log much else--if your code is properly decomposed into methods then this will document the execution flow through your application.</p> <p>Do not make the mistake of not logging enough info because you are worried about the performance hit--measure this so you are happy with the overhead, but are confident that you are logging enough to diagnose faults purely based on the info that is in the log. What you do not want to have to do is switch the logging on to more detail <em>after</em> your customer has reported a fault, and then hope the fault occurs again.</p> <p>I also use a DEBUG logging level which logs practically everything. This is only used in dev/test, or perhaps in production but only after consultation with the customer.</p>
 

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