有没有办法将旧日志文件从 log4net RollingLogFileAppender 移动到不同的文件夹中?
我配置了一个滚动文件附加器:
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="appname" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<datePattern value="'.'yyyyMMdd'.log'" />
<maxSizeRollBackups value="30" />
<maximumFileSize value="10MB" />
<staticLogFileName value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
这工作正常,但我想知道是否有办法将旧日志文件移动到“存档”文件夹中,而不是将它们移动到同一文件夹中?
I have a rolling file appender configured with this:
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="appname" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<datePattern value="'.'yyyyMMdd'.log'" />
<maxSizeRollBackups value="30" />
<maximumFileSize value="10MB" />
<staticLogFileName value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
This works fine, but I was wondering if there was a way to move the old log files into an "archive" folder, instead of having them moved to the same folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您始终可以打开 RollingLogFileAppender.cs 并将其修改为您想要的任何内容。它是开源的,伙计。而且这个类真的很容易扩展。就我个人而言,我讨厌它的日志文件命名风格,并且我有自己的 RollingLogFileAppender 来取悦我。 :)
You can always open RollingLogFileAppender.cs and modify it to anything you want. It's open source, mate. And this class is really easy to extend. Personally I hate its naming style for log files, and I have my own RollingLogFileAppender to please me. :)