Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will log4net ever hangs the application?

Tags:

log4net

I am using ColoredConsoleAppender, I am worried about if it will ever hang my application. Anyone has experience

like image 207
user496949 Avatar asked Dec 16 '10 05:12

user496949


2 Answers

From the log4net site: http://logging.apache.org/log4net/release/faq.html

No. log4net is not reliable. It is a best-effort and fail-stop logging system.

By fail-stop, we mean that log4net will not throw unexpected exceptions at run-time potentially causing your application to crash. If for any reason, log4net throws an uncaught exception (except for ArgumentException and ArgumentNullException which may be thrown), please send an email to the [email protected] mailing list. Uncaught exceptions are handled as serious bugs requiring immediate attention.

I personally use it all the time and have never had an issue.

like image 120
Dean Avatar answered Sep 28 '22 06:09

Dean


@ralf.w. already shows the full symptoms. I can rephrase as I recently meet the same issue too.

  1. Develop a console application that uses ColoredConsoleAppender (or ConsoleAppender) to print out logs.
  2. Develop another application (WinForms in my case) to execute that console (using Process.Start). UseShellExecute = false so as to redirect standard output and error. CreateNoWindow = true. WindowStyle = Hidden.

Then on a few machines (or remote desktop sessions), log4net will hang the console application, and in the hang dumps you can see it weirdly waits for a write to the stream to finish.

Hard to reproduce on a normal machine (like mine), so hard to investigate further though log4net is open source.

The workaround can be as simple as show the console application as minimized (instead of hidden), and/or change other ProcessStartInfo settings.

like image 20
Lex Li Avatar answered Sep 28 '22 05:09

Lex Li