如何指定log4net的通用应用程序数据文件夹? [英] How to specify common application data folder for log4net?

查看:435
本文介绍了如何指定log4net的通用应用程序数据文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望log4net将日志文件(使用RollingFileAppender)写入公共应用程序数据文件夹的子文件夹(例如C:\Documents and Settings\All Users\Application Data\Company\Product\Logs) 。

但是,在Win XP中,没有指定此文件夹的环境变量。我们有%ALLUSERSPROFILE%,我们有%APPDATA%,但没有什么像% ALLUSERSAPPDATA%

编程中,我可以使用 Environment.SpecialFolder.CommonApplicationData ,但是我需要把它放在log4net config,这样:

I want log4net to write log files (using RollingFileAppender) to a subfolder of the common application data folder (e.g. C:\Documents and Settings\All Users\Application Data\Company\Product\Logs).
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%\Company\Product\Logs\error.log" />
</appender>

好的,我们可以在我们的设置中定义这个,但也许有人想出了一个更好的主意? / p>

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆