common location of log file in log4net not working?

纵饮孤独 提交于 2019-12-11 09:16:58

问题


I have an issue with the location of log file in log4net.

I gave this node for the location to create the log file

 <file type="log4net.Util.PatternString" value="%ALLUSERSPROFILE%\MyProject\error.txt/>

As I think it should create the log file in user folder. But this one is creating in the

bin\debug\ALLUSERSPROFILE\MyProject\error.txt

Even I tried AppData also but its behaving the same. Am I doing any mistake??

Is it required any converter to convert environment variables?


回答1:


From the documentation Apache log4net file appender

This example shows how to configure the file name to write to using an environment variable TMP <file value="${TMP}\log-file.txt" />




回答2:


I think you should use it as follows:

<file type="log4net.Util.PatternString" value="${ALLUSERSPROFILE}\MyProject\error.txt/>


来源:https://stackoverflow.com/questions/5550402/common-location-of-log-file-in-log4net-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!