Log4net可以在新创建的AppDomain中运行吗
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这应该可行,但您需要为新的 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.