ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Purge Old Mongo Logs without User Intervention

Purge Old Mongo Logs without User Intervention

原创 Linux操作系统 作者:jieforest 时间:2012-05-28 12:46:44 0 删除 编辑

One of thecoolest feature of Mongo is the concept of Capped Collection, or “fixed size” collection. They are based ona FIFO queue where the first record to be discharded is the first inserted, andthis is exceptional to create a log-collection that automatically purge all oldlogs without any user intervention.


To be ableto automatically enable this feature on the Log4Net Mongo appender you need to do a little modification to thecode, this is because the original code simply gets a reference to thecollection with this code.

CODE:

connection = MongoServer.Create(mongoConnectionString.ToString());
connection.Connect();
var db = connection.GetDatabase(DatabaseName);
collection = db.GetCollection(CollectionName);






来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/301743/viewspace-731251/,如需转载,请注明出处,否则将追究法律责任。

下一篇: A Hadoop Primer
请登录后发表评论 登录
全部评论

注册时间:2008-04-23

  • 博文量
    442
  • 访问量
    521877