Log4net可以在新创建的AppDomain中运行吗

发布于 2024-09-19 19:00:31 字数 191 浏览 3 评论 0原文

我有一个 Windows 服务,它在新的 AppDomain 中执行代码片段。创建此 AppDomain 只是为了执行这段代码,然后销毁。我使用 log4net 进行日志记录,因为我喜欢它的简单性和灵活性。它在默认的 AppDomain 中工作得很好,但新创建的 AppDomain 内的日志记录语句不会被记录。这是 log4net 中的限制还是只是我没有正确设置它。

I have a windows service that executes pieces of code in a new AppDomain. This AppDomain is created just for executing this pieces of code then destroyed thereafter. I am using log4net for logging purpose since I like its simplicity and flexibility. It works just fine in the default AppDomain, but logging statements inside the newly create AppDomain don't get logged. Is this a limitation within log4net or it's just that I am not setting it up right.

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

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

发布评论

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

评论(1

夜无邪 2024-09-26 19:00:31

我认为这应该可行,但您需要为新的 AppDomain 初始化 log4net。如果您登录到文件,您可能会遇到锁定问题。

另请参阅此问题

I think that should work but you need to initialize log4net for the new AppDomain. If you log to a file you may experience locking issues.

See also this question.

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