Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Use log4net</p> <p>The advantage of using log4net is that you can check the logging and control it with far more flexibility than you will account for within your code.</p> <p>If you were logging to the event log, and seeing problems and no event log entries, you could always have switched to a file-appender log and have seen it working... which would have then told you that it was something to do with the event log.</p> <p>log4net is also defensive, it won't crash your program if it fails to write the log entry. So you wouldn't have seen this happen (so you wouldn't have your logs files, but your program would be running and again you could've specified a second logging method to get log files).</p> <p>The key bit in the log4net documentation is this:</p> <blockquote> <p>[log4net] is a best-effort and fail-stop logging system.</p> <p>By fail-stop, we mean that <strong>log4net will not throw unexpected exceptions at run-time potentially causing your application to crash</strong>. If for any reason, log4net throws an uncaught exception (except for ArgumentException and ArgumentNullException which may be thrown), please send an email to the log4net-user@logging.apache.org mailing list. Uncaught exceptions are handled as serious bugs requiring immediate attention.</p> <p>Moreover, log4net will not revert to System.Console.Out or System.Console.Error when its designated output stream is not opened, is not writable or becomes full. This avoids corrupting an otherwise working program by flooding the user's terminal because logging fails. However, log4net will output a single message to System.Console.Error and System.Diagnostics.Trace indicating that logging can not be performed. </p> </blockquote> <p>(my emphasis)</p> <p>For most things, there is a library that does it better than you will. The best thing is to never re-invent, log4net solves logging in .Net and will make your life easier.</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