log4net 会挂起应用程序吗?

发布于 2024-10-07 17:02:32 字数 58 浏览 0 评论 0原文

我正在使用 ColoredConsoleAppender,我担心它是否会挂起我的应用程序。 谁都有经验

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笔落惊风雨 2024-10-14 17:02:32

来自 log4net 站点:
http://logging.apache.org/log4net/release/faq.html

不,log4net 不可靠。它是一个尽力而为、故障停止的日志系统。

通过故障停止,我们的意思是 log4net 不会在运行时引发可能导致应用程序崩溃的意外异常。如果出于任何原因,log4net 抛出未捕获的异常(可能抛出的 ArgumentException 和 ArgumentNullException 除外),请发送电子邮件至 [电子邮件受保护] 邮件列表。未捕获的异常将被视为需要立即关注的严重错误。

我个人一直在使用它并且从未遇到过问题。

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.

生生漫 2024-10-14 17:02:32

@ralf.w。已经显示出全部症状。我可以重新表述一下,因为我最近也遇到了同样的问题。

  1. 开发一个使用 ColoredConsoleAppender(或 ConsoleAppender)打印日志的控制台应用程序。
  2. 开发另一个应用程序(在我的例子中是 WinForms)来执行该控制台(使用 Process.Start)。 UseShellExecute = false 以便重定向标准输出和错误。创建无窗口 = true。窗口样式 = 隐藏。

然后,在几台计算机(或远程桌面会话)上,log4net 将挂起控制台应用程序,并且在挂起转储中,您可以看到它奇怪地等待对流的写入完成。

很难在普通机器(比如我的)上重现,因此很难进一步研究,尽管 log4net 是开源的。

解决方法可以很简单,只需将控制台应用程序显示为最小化(而不是隐藏),和/或更改其他 ProcessStartInfo 设置。

@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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文