Log4net RollingFileAppender大小rollingStyle文件扩展名 [英] Log4net RollingFileAppender Size rollingStyle file extension

查看:367
本文介绍了Log4net RollingFileAppender大小rollingStyle文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用RollingFileAppender和"size"滚动样式.默认情况下,它会创建带有编号扩展名的备份文件,这让我很烦.是否可以更改它,使其始终使用已定义的扩展名(例如.txt或.log)并将该数字作为文件名的一部分插入?

I am using the RollingFileAppender and the Size rollingStyle. By default it creates backup files with a numbered extension, this drives me nuts. Is it possible to change it so it always uses a defined extension (say .txt or .log) and inserts the number as part of the file name?

例如:

myapp.log
myapp.1.log
myapp.2.log
myapp.3.log

myapp.log
myapp.1.log
myapp.2.log
myapp.3.log

这是我当前的配置:

<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="myapp.log"/>
    <appendToFile value="true"/>
    <rollingStyle value="Size"/>
    <maximumFileSize value="1MB"/>
    <maxSizeRollBackups value="10"/>
    <staticLogFileName value="true"/>
    <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date{ISO8601} [%3thread] %-5level %logger{3}: %message%newline" />
    </layout>
</appender>

推荐答案

PreserveLogFileNameExtension 属性设置为true应该可以解决问题. 注意:此属性在当前发布的版本1.2.10中不可用. 是当前资源的一部分.如果您掌握并构建源代码,那就很好了.

The PreserveLogFileNameExtension property set to true should do the trick. Note: this property is not available in the currently released version 1.2.10 but is part of the current source. If you grab and build the source you're good to go.

更新:很高兴看到log4net向前发展.已发布1.2.11版,并带有PreserveLogFileNameExtension属性.

Update: it is great to see log4net is moving forward. Version 1.2.11, and with it the PreserveLogFileNameExtension property, have been released.

这篇关于Log4net RollingFileAppender大小rollingStyle文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆