Log4net 附加程序文件名问题
我有一个像这样的附加程序设置
<appender name="Scheduler_Appender" type="log4net.Appender.RollingFileAppender">
<file value="c:\temp\ApplicationLog.txt"/>
<rollingStyle value="Date"/>
<datePattern value="yyyyMMdd"/>
<appendToFile value="true"/>
<staticLogFileName value="true"/>
<layout type="MinLayout">
<locationInfo value="true"/>
</layout>
</appender>
当第一次创建日志文件时,文件名只是 ApplicationLog.txt 这是正确的。
但是,当日志记录滚动时 - 生成的文件名是 ApplicationLog.txt20100323 (例如),而不是 ApplicationLog20100323.txt
如何更改配置,以便文件滚动到 [FileName][Date].[ext] 而不是 [FileName] ].[ext][日期]
谢谢
更新
我尝试了这个,只是一些实验,但现在由于某种原因它生成了带有 .pxp 扩展名的文件...
<appender name="Scheduler_Appender" type="log4net.Appender.RollingFileAppender">
<file value="c:\temp\Scheduler"/>
<rollingStyle value="Date"/>
<datePattern value="yyyyMMdd.txt"/>
<appendToFile value="true"/>
<staticLogFileName value="false"/>
<layout type="MinLayout">
</layout>
</appender>
I have an appender setup like this
<appender name="Scheduler_Appender" type="log4net.Appender.RollingFileAppender">
<file value="c:\temp\ApplicationLog.txt"/>
<rollingStyle value="Date"/>
<datePattern value="yyyyMMdd"/>
<appendToFile value="true"/>
<staticLogFileName value="true"/>
<layout type="MinLayout">
<locationInfo value="true"/>
</layout>
</appender>
When the log file first gets created the file name is simply ApplicationLog.txt this is correct.
However when the logging rolls - the filename that gets generated is ApplicationLog.txt20100323 (for example), and not ApplicationLog20100323.txt
How can I change the configuration so files are rolled to [FileName][Date].[ext] rather than [FileName].[ext][Date]
Thanks
Update
I tried this, just some experiment, but now its generating files with a .pxp extension for some reason...
<appender name="Scheduler_Appender" type="log4net.Appender.RollingFileAppender">
<file value="c:\temp\Scheduler"/>
<rollingStyle value="Date"/>
<datePattern value="yyyyMMdd.txt"/>
<appendToFile value="true"/>
<staticLogFileName value="false"/>
<layout type="MinLayout">
</layout>
</appender>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信您想要的设置是
PreserveLogFileNameExtension
:注意: 此属性在当前发布的二进制文件(版本 1.2.10.0)中不可用,因此您必须获取最新的源代码然后从那里开始。
I believe the setting you want is
PreserveLogFileNameExtension
:Note: this property is not available in the currently released binary (version 1.2.10.0) so you would have to grab the latest source and go from there.