更新时间:2023-10-31 23:51:46
如果您希望将日志文件放置在运行时将决定的指定位置,则该文件可能是您的项目输出目录,则可以配置
If you want your log file to be place at a specified location which will be decided at run time may be your project output directory then you can configure your .config
file entry in that way
<file type="log4net.Util.PatternString" value="%property{LogFileName}.txt" />
,然后在调用log4net configure
之前的代码中,按如下所示设置新路径
and then in the code before calling log4net configure
, set the new path like below
log4net.GlobalContext.Properties["LogFileName"] = @"E:\\file1"; //log file path
log4net.Config.XmlConfigurator.Configure();
这有多简单? :)