zoukankan      html  css  js  c++  java
  • rollingstyle in log4net

    RollingFileAppender.RollingStyle Property

     The default rolling style is Composite.

    When set to Once this appender's AppendToFile property is set to false, otherwise the appender would append to a single file rather than rolling the file each time it is opened. 

    RollingFileAppender.CountDirection Property

    Remarks

    Indicates if the current file is the lowest numbered file or the highest numbered file.

    By default newer files have lower numbers (CountDirection < 0), i.e. log.1 is most recent, log.5 is the 5th backup, etc... 

    小于0的时候,

    第一次roll file,把log重命名为log.1,然后新建log

    第二次roll file,把log.1重命名为log.2,把log重名为log.1,然后新建log

    CountDirection >= 0 does the opposite i.e. log.1 is the first backup made, log.5 is the 5th backup made, etc. For infinite backups use CountDirection >= 0 to reduce rollover costs.

    大于0的时候,

    第一次roll file,把log重名为log.1,新建log

    第二次roll file,把log重名为log.2,新建log

    The default file count direction is -1.

    Log4Net RollingFileAppender with composite rolling style is overwritting data

    RollingFileAppender.RollingMode Enumeration

    I want it to roll on just the date. By default, though, the rolling is set to composite, so it rolls on date or size, whichever comes first.

    Member nameValueDescription
      Once 0 Roll files once per program execution
      Size 1 Roll files based only on the size of the file
      Date 2 Roll files based only on the date
      Composite 3 Roll files based on both the size and date of the file             

    Log4net preserveLogFileNameExtension not working

    this is my log4net configuration, the rollover log file is created wrong extension.

    The first file created with name of log_debug.txt and the rollover file created with log_debug.txt.1. but ideally it should be log_debug.1.txt.

    I used preserveLogFileNameExtension value to be true, but it seems not working. Can you please check and let me know if anything wrong?

     
     
     
     

    Log4net RollingFileAppender Size rollingStyle file extension

    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.

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

    RollingFileAppender.StaticLogFileName Property

    true if always should be logged to the same file, otherwise false

    Remarks

    By default file.log is always the current file.

    Optionally file.log.yyyy-mm-dd for current formatted datePattern can by the currently logging file (or file.log.curSizeRollBackup or even file.log.yyyy-mm-dd.curSizeRollBackup).

    This will make time based rollovers with a large number of backups much faster as the appender it won't have to rename all the backups! 

    StaticLogFileName meaning?

    If there's true, you always log to your example.log file, which is renamed as part of rollover procedure.
    If there's false, you always log to example.log.yyyy-MM-dd.N (in common case) file and rollover is just creating one more such file.

    意思是说,当前写日志的那个文件名字是否保持不变。默认是true。

    如果为true的话,日志每次都往error.log里面写,等到了第二天,会把之前的errorlog重命名为error-20200702.log。然后重新创建一个error.log。

    如果是false的话,日志每次都往带日期的日志里面写,比如error-20200701.log,到了第二天直接创建一个新的error-20200702.log。

    RollingFileAppender.MaximumFileSize Property 

    public string MaximumFileSize { get; set; }
    Remarks

     

    This property allows you to specify the maximum size with the suffixes "KB", "MB" or "GB" so that the size is interpreted being expressed respectively in kilobytes, megabytes or gigabytes.

    For example, the value "10KB" will be interpreted as 10240 bytes.

    The default maximum file size is 10MB.

    If you have the option to set the maximum file size programmatically consider using the MaxFileSize property instead as this allows you to set the size in bytes as a Int64.             

  • 相关阅读:
    高效是如何来的
    find 删除指定日期的文件
    MySQL基础教程
    grep search information
    关于进程的问题
    linux useradd 命令
    host and ip 的关系
    git cherry-pick 教程
    正则练习
    正则表达式-获取
  • 原文地址:https://www.cnblogs.com/chucklu/p/10207163.html
Copyright © 2011-2022 走看看