如何为 log4net 指定通用应用程序数据文件夹? [英] How to specify common application data folder for log4net?
问题描述
我希望 log4net 将日志文件(使用 RollingFileAppender)写入通用应用程序数据文件夹的子文件夹(例如 C:Documents and SettingsAll UsersApplication DataCompanyProductLogs).
但是,在 Win XP 上,没有指定此文件夹的环境变量.我们有 %ALLUSERSPROFILE%
,我们有 %APPDATA%
,但没有像 %ALLUSERSAPPDATA%
这样的东西.
以编程方式,我可以使用 Environment.SpecialFolder.CommonApplicationData
,但我需要将它放在 log4net 配置中,如下所示:
I want log4net to write log files (using RollingFileAppender) to a subfolder of the common application data folder (e.g. C:Documents and SettingsAll UsersApplication DataCompanyProductLogs).
However, on Win XP, there is no environment variable that specifies this folder. We have %ALLUSERSPROFILE%
, we have %APPDATA%
, but there is nothing like %ALLUSERSAPPDATA%
.
Programatically, I could use Environment.SpecialFolder.CommonApplicationData
, but I need to put it in the log4net config, something like this:
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="%ALLUSERSAPPDATA%CompanyProductLogserror.log" />
</appender>
好的,我们可以在设置中定义它,但也许有人想出了更好的主意?
OK, we could define this in our setup, but maybe someone comes up with a better idea?
推荐答案
log4net 邮件列表上的这篇帖子 解释了如何定义自己的路径替换变量.
This posting on the log4net mailinglist explains how you can define your own path replacement variables.
这篇关于如何为 log4net 指定通用应用程序数据文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!