具有静态文件扩展名的 Log4Net 复合 RollingFileAppender
当前版本的 Log4net 是否有办法创建具有复合滚动样式的 RollingFileAppender,其中滚动文件始终保留给定的扩展名(在我的情况下为 .log)?
我想要的格式示例:
MyLog.log
MyLog.2011-04-10.1.log
MyLog.2011-04-10.2.log
MyLog.2011-04-10.3.log
我发现 这篇文章 上面写着有一个“PreserveLogFileNameExtension”属性,但它不包含在官方二进制文件中。现在还是这样吗?
如果是这样:谁能解释为什么这个属性仍然不是 Log4Net 的官方部分?我对使用自定义构建有点怀疑,但也许我不应该这样?
我也很好奇为什么默认功能不保留文件扩展名。我不明白为什么它会让用户知道所有日志文件都有不同的扩展名。
编辑:通过这样做让它工作:
1:下载并构建log4net源代码
2:应用这些补丁: https://issues.apache.org/jira/browse/ LOG4NET-64
3:在配置中将 PreserveLogFileNameExtension 设置为“true”。
Does the current version of Log4net have a way to create a RollingFileAppender with composite rolling style where the rolled files always preserves the given extension (.log in my case)?
Example of the format I would like:
MyLog.log
MyLog.2011-04-10.1.log
MyLog.2011-04-10.2.log
MyLog.2011-04-10.3.log
I found this post which says that there is a "PreserveLogFileNameExtension" property, but that it's not included in the official binaries. Is this still the case?
If so: Can anyone explain why this property is still not an offical part of Log4Net? I am a bit sceptical to use a custom build, but maybe I should not be?
I am also curious to know why the default functionality does not preserve the file extension. I do not see why it would gain the user that all the log files have different extensions.
Edit: Got it working by doing this:
1: Downloading and building the log4net source code
2: Applying these patches: https://issues.apache.org/jira/browse/LOG4NET-64
3: Setting PreserveLogFileNameExtension to "true" in the config.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您尝试过这些参数吗?
它将保留扩展名,但会在每个文件名中为您提供一个日期,如下所示。
也许可以将其与尺寸滚动结合起来?
Have you tried these parameters?
It will preserve the extension, but will give you a date in every filename like this.
Maybe it is possible to combine this with the size rolling?
情况没有改变。 log4net 没有更新版本。我不清楚何时(是否)会有新版本......
我认为您不需要太担心使用自定义构建。测试你的软件,如果它能工作那就足够好了。
编辑:有一个新版本应包含 LOG4NET-64。当然,您仍然可以坚持您的自定义构建。
The situation is unchanged. There is no newer release of log4net. It is quite unclear to me when (if) there will be a new release...
I think you do not need to worry to much about using a custom build. Test your software, if it works it is good enough.
EDIT: There is a new release that should include LOG4NET-64. Of course you can still stick to your custom build.
我正在使用此配置:
要获取如下文件名:
I'm using this configuration:
To get filenames like: