在app.config中设置边距以进行日志记录 [英] Set margins in app.config for logging

查看:65
本文介绍了在app.config中设置边距以进行日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在app.config中是否有用于为日志文件设置边距的元素?
还有一种方法可以将日期戳放在".txt"扩展名之前,因为它看起来像:InfoDebug_Logging_TestSimulator.txt.2011-05-20
我想要这样:
InfoDebug_Logging_TestSimulator_2011-05-20.txt

Hi,

Is there an element for setting up margins for a logging file in the app.config?
Is there also a way for putting the datestamp before the ".txt" extension because now it''s looks like: InfoDebug_Logging_TestSimulator.txt.2011-05-20
I want it like this:
InfoDebug_Logging_TestSimulator_2011-05-20.txt

<appender name="RollingFileAppender1" type="log4net.Appender.RollingFileAppender">
    <file value="Logging\InfoDebug_Logging_TestSimulator.txt" />
    <appendToFile value="true" />
    <!--<rollingStyle value="Size" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="10000" />
    <staticLogFileName value="true" />-->
    <!-- Alternatively, roll on date -->
    <rollingStyle value="Date" />
    <param name="DatePattern1" value=".yyyy-MM-dd-HH.\t\x\t" />
    <maxSizeRollBackups value="20" />
    <maximumFileSize value="15MB" />
    <filter type="log4net.Filter.LevelRangeFilter">
    <acceptOnMatch value="true" />
    <levelMin value="DEBUG" />
    <levelMax value="FATAL" />
    </filter>
    <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date{HH:mm:ss.fff} %-5level %-32logger %-30M %message%newline" />
    </layout>
  </appender>


在此先感谢


thanks in advance

推荐答案

.\t\x\t"可能是问题.

更改<file value="Logging\InfoDebug_Logging_TestSimulator.txt" />
并尝试使用.\tx\t<datePattern value="yyyyMMdd_HH''.txt''"/>
.\t\x\t" could be the problem.

Change <file value="Logging\InfoDebug_Logging_TestSimulator.txt" />
and try using .\tx\t or <datePattern value="yyyyMMdd_HH''.txt''"/>


这篇关于在app.config中设置边距以进行日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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