问题描述
我正在使用RollingLogFileAppender
,它工作得很好,并且正在滚动到新文件中.但是它将在文件的末尾添加.1,.2等.因此,我最终使用.log.1
,.log.2
等.因此,每个文件在技术上都具有资源管理器不知道的新扩展名,因此我不能只双击打开文件.
I am using the RollingLogFileAppender
and it works great and it's rolling over into new files. But it's adding the .1, .2, etc at the very end of the file. So I end up with .log.1
, .log.2
, etc. So every file technically has a new extension that explorer doesn't know, so I can't just double click on a file to open.
如何获取滚动文件追加程序以在文件扩展名之前插入该索引?
How can I get the rolling file appender to insert that index BEFORE the file extension?
我想要的是
- .1.log
- .2.log
当前文件的奖金始终为.0.log
,这样它们就始终在资源管理器中正确排序.
Bonus would be for the current file to always be .0.log
, that way they always sort correctly in explorer.
添加了我当前的配置设置
added my current config settings
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<file value="App_Data\\Logs\\" />
<datePattern value="dd.MM.yyyy'.log'" />
<staticLogFileName value="false" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="5MB" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<logger name="File">
<level value="All" />
<appender-ref ref="RollingLogFileAppender" />
</logger>
</log4net>
推荐答案
您只需要在RollingFileAppender上使用PreserveLogFileNameExtension属性.
You just need to use the PreserveLogFileNameExtension property on the RollingFileAppender.
请参见以下问题:
Log4net RollingFileAppender大小rollingStyle文件扩展名
这篇关于如何在日志文件名中的文件扩展名之前附加滚动索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!