基于MongoDB的日志系统 Mongodb-Log

fmms 13年前
     <p>mongodb-log 是一个基于MongoDB的Python日志系统。</p>    <p>MongoDB 的 Capped Collection是一个天生的日志系统,MongoDB自己的oplog就是用它来存储的,Capped Collection的特点是可以指定Collection的大小,当记录总大小超过设定大小后,老的数据会被自动抹掉用于存储新的内容。</p>    <p>示例代码:</p>    <pre class="brush:python; toolbar: true; auto-links: false;">import logging  from mongolog.handlers import MongoHandler  log = logging.getLogger('demo')  log.setLevel(logging.DEBUG)  log.addHandler(MongoHandler.to(db='mongolog', collection='log'))  log.debug('Some message')</pre>项目地址:    <a href="/misc/goto?guid=4958190767341031547" target="_blank">https://github.com/andreisavu/mongodb-log</a>    <p></p>