本文介绍了如何使用复合命名的卷备份配置静态日志文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了此配置,但始终将日期添加到当前文件('log.20130805.0.log').

I used this config but a date is always added to the current file ('log.20130805.0.log').

<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="Logs/logFile.log" />
    <appendToFile value="true" />
    <preserveLogFileNameExtension value="true" />
    <rollingStyle value="Composite" />
    <datePattern value=".yyyyMMdd" />
    <maximumFileSize value="10MB" />
    <countDirection value="1"/>
    <maxSizeRollBackups value="-1" />
    <staticLogFileName value="false" />
    <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%date [%thread] %-5level %logger - %message%newline" />
    </layout>
</appender>

该配置的结果是:

log.20130805.0.log
log.20130805.1.log
log.20130805.2.log
log.20130805.3.log

staticLogFileName = true得到的是:

What I get with staticLogFileName = true is :

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

我想要的是:

log.log
log.20130805.1.log
log.20130805.2.log
log.20130805.3.log

推荐答案

不幸的是,基于这些提示,我猜不可能(对于当前的RollingFileAppender实现):

Based on these tips I guess it isn't possible, unfortunately (with the current implementation of RollingFileAppender):

http://geekswithblogs. net/rgupta/archive/2009/03/03/tips-on-using-log4net-rollingfileappender.aspx

这篇关于如何使用复合命名的卷备份配置静态日志文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 07:15