配置 log4net 以在 WPF 应用程序中使用独立存储

发布于 2024-09-25 08:26:11 字数 381 浏览 6 评论 0原文

我想使用 log4net 的 RollingAppender 写入隔离存储,但我不知道如何配置 log4net 来执行此操作。需要明确的是,我正在尝试在已安装的 WPF 应用程序中执行此操作,因此我不会遇到一些 Silverlight 用户已经发布的问题。

我认为我最好的机会是动态设置文件路径,如本答案中所述,动态设置附加程序文件路径的最佳方式,但当然您无权访问独立存储的文件路径。

任何人都可以确认是否可以设置 log4net RollingAppender 来使用隔离存储,如果可以,如何设置?

I'd like to use log4net's RollingAppender to write to isolated storage, but I can't figure out how to configure log4net to do so. To be clear, I'm trying to do this in an installed WPF application so I don't have some of the issues that some of the Silverlight users have already posted.

I thought my best chance was to dynamically set the file path as described in this answer, Best way to dynamically set an appender file path, but of course you don't have access to the isolated storage's file path.

Can anyone confirm whether it's possible to setup a log4net RollingAppender to use the isolated storage, and if so how?

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

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

发布评论

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

评论(1

沫尐诺 2024-10-02 08:26:11

我不知道这是否对您有帮助,但我发布了一个为 NLog 创建新目标的想法,该目标可以写入隔离存储。我没有测试过,但看起来很简单。

以下是我发布建议作为答案的问题的链接:

使用NLog 到独立存储

假设它有效,那么在 log4net 中创建类似的东西可能会非常容易。当然,它不会具有与 RollingAppender 相同的功能,因此即使它确实有效,它对您来说也可能没有多大用处。

I don't know if this will help you, but I posted an idea for creating a new Target for NLog that could write to isolated storage. I have not tested it, but it seems pretty straightforward.

Here is the link to the question where I posted my suggestion as an answer:

Logging with NLog into an Isolated Storage

Assuming it works, it would probably be pretty easy to create something similar in log4net. Of course, it would not have the same capabilities as the RollingAppender, so it might not be of much use to you, even if it does work.

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