惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
量子位
T
Tailwind CSS Blog
T
Threatpost
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LangChain Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
T
Troy Hunt's Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
T
Tor Project blog
T
The Blog of Author Tim Ferriss
I
Intezer
P
Privacy & Cybersecurity Law Blog
美团技术团队
N
Netflix TechBlog - Medium
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI

博客园 - From Ocean

how to solve error when start Hyper-V quick create app error log4j 2使用properties文件进行配置 (Asp.Net)转载-用Powershell 建立IIS web site (DP)降低代码重构的风险(转载) (Life)牛人的学习方法(转译文) (WPF)WPF事件要点-WPF宝典笔记 (WPF)路由事件要点-WPF宝典笔记 (WPF)依赖属性要点-WPF宝典笔记 (Ruby)Ubuntu12.04安装Rails环境 (Ruby)方法的一些有趣的地方--待补充 (Ruby)Ruby中区块用的一些潜藏关键字 (Ruby)类变量,实例变量,类常量,如何访问变量 (WPF)WPF要点之命令-深入浅出WPF笔记 (WPF)WPF要点之事件-深入浅出WPF笔记 (Algorithm)计算机科学中最重要的32个算法_转载infoq上的文章 (转载)postgresql无法远程登录(设置远程登陆的三点注意事项) (.Net,DevExpress)关于devexpress部分aspx控件需要注意的细节_持续补充ing (.Net,DevExpress)devexpress源码编译需要注意的地方 (Silverlight,WCF,Socket,Cocurrency)一周浏览碰到不错的文章
(转载)Tips on using log4net RollingFileAppender by Rohit Gupta
From Ocean · 2013-03-04 · via 博客园 - From Ocean

转载一篇关于log4net的文章(http://geekswithblogs.net/rgupta/archive/2009/03/03/tips-on-using-log4net-rollingfileappender.aspx)

By Default we have the following values for following properties of RollingFileAppender

  • staticLogFileName = true
  • countDirection = –1
  • rollingStyle = Composite
  • maxSizeRollBackups = 0 // be careful with this
  • maximumFileSize = “10MB”
  • datePattern = ".yyyy-MM-dd"

staticLogFileName indicates whether you need to keep writing (log) to the same file all the time. You will need to set it to false when using Date as the rolling style and you have large number of backups.

Optionally file.log.yyyy-mm-dd for current formated datePattern can by the currently logging file (or file.log.curSizeRollBackup (rollingStyle=Size) or even file.log.yyyy-mm-dd.curSizeRollBackup --- (rollingStyle=Composite)) This will make time based roll overs with a large number of backups much faster -- it won't have to rename all the backups!

Recommend to leave it at its default value “true”

countDirection when its value is –1, then newest logfile backup will always be file.log.1.. hence this would involve more number of file renaming.

By default newer files have lower numbers. (countDirection < 0) ie. log.1 is most recent, log.5 is the 5th backup, etc... countDirection > 0 does the opposite ie. 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.

rollingStyle can be either Date, Size or Composite. the default setting Composite, uses a combination of Size and Date settings. Thus if you have the datePattern set to “.yyyy-MM-dd” and maxSizeRollBackups set to 10, themn it will maintain 10 log backups for each day.

If you have the DatePattern set to “.yyyy-MM-dd HH:mm” and maxSizeRollbackups = 10 then it will maintain 10 logfile backups per minute

Samples:

   1: <appender name="RollingFileAppenderV1" type="log4net.Appender.RollingFileAppender">
   2:     <file type="log4net.Util.PatternString" value="F:\HornetFeed\%property{LogName}" />
   3:     <appendToFile value="true" />
   4:     <rollingStyle value="Size" />
   5:     <maxSizeRollBackups value="-1" />
   6:     <maximumFileSize value="5000KB" />
   7:     <staticLogFileName value="true" />
   8:     <countDirection value="1"/>
   9:     <layout type="log4net.Layout.PatternLayout">
  10:         <conversionPattern value="%m%n" />
  11:     </layout>
  12:     <filter type="log4net.Filter.PropertyFilter">
  13:         <Key value="Version" />
  14:         <StringToMatch value="1" />
  15:     </filter>
  16:     <filter type="log4net.Filter.DenyAllFilter" />
  17: </appender>

This will create infinite file backups with the countdirection > 0 so that the newest file has the latest/greatest name i.e. log.5 for the newest backup (5th backup)

   1: <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
   2:         <file value="logfile" />
   3:         <appendToFile value="true" />
   4:         <rollingStyle value="Composite" />
   5:         <datePattern value=".yyyyMMdd-HHmm" />
   6:         <maxSizeRollBackups value="10" />
   7:         <maximumFileSize value="1MB" />
   8:         <countDirection value="1"/>
   9:         <layout type="log4net.Layout.PatternLayout">
  10:             <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
  11:         </layout>
  12:     </appender>

This is a Composite RollingFileAppender which keeps max of 10 1MB log backups every minute