log4net的 - FileAppender写入新的条目在文件的开头 [英] log4net - FileAppender writing new entries at the beginning of file

查看:223
本文介绍了log4net的 - FileAppender写入新的条目在文件的开头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时,可以在log4net的配置FileAppender到日志文件的开头添加新条目?目前,它在最后添加条目,阅读最新的条目需要滚动整个日志下来。这将是更舒适的从开始到读

Is is possible to configure FileAppender in log4net to add new entries at the beginning of log file? Currently it is adding entries at the end and reading newest entries requires scrolling whole log down. It would be more comfortable to read from the beginning.

推荐答案

我不知道该选项在log4net的使用(我不这么认为),但即使是可用的我会建议不要使用它。

I don't know if that option is available in log4net (I wouldn't think so), but even if it's available I would advice against using it.

附加到文件是一个相当便宜的操作。字节都只是添加到文件的末尾。 prepending至另一方面一个文件是相当昂贵的。整个文件已经被读取并重写与在开始时加入新的数据。这也意味着它扩展严重,即操作需要很多时间,当文件变大。

Appending to a file is a quite cheap operation. The bytes are just added to the end of the file. Prepending to a file on the other hand is rather expensive. The entire file has to be read and rewritten with the new data added at the beginning. This also means that it scales badly, i.e. the operation takes a lot longer when the file gets bigger.

如果你想以不同的顺序显示的条目,你应该寻找的程序选项所显示的日志,或者寻找一个替代品,可以以相反的顺序显示条目。

If you want the entries displayed in a different order, you should look for that option in the program that is displaying the log, or look for a replacement that can display the entries in reverse order.

这篇关于log4net的 - FileAppender写入新的条目在文件的开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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