我的程序默认会在用户的appdata文件夹生成一系列的数据缓存目录,同时日志也想放在这里,使用log4Net做日志工具,在app.config中配置Log4Net的输出目录,该怎么设,我只知道<file value="Log\\"/>是放在程序根目录下的Log文件夹下,在配置文件中怎么获取那个appdata目录呢,程序中是System.Environment.GetEnvironmentVariable("AppData");这样获取的
http://logging.apache.org/log4net/release/config-examples.html
参考 FileAppender章节
<appender name="FileAppender" type="log4net.Appender.FileAppender"> <file value="${TMP}\log-file.txt" /> <appendToFile value="true" /> <encoding value="unicodeFFFE" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout> </appender>
This example shows how to configure the file name to write to using an environment variable TMP. The encoding to use to write to the file is also specified.