Search code examples
djangomongodbloggingcapped-collections

Is there a way to use MongoDB capped collections with Django's builtin logging module?


I'm interested in using MongoDB capped collections to log system activity on my Django project, in a similar way to what Django's builtin logging module already does.

Is there any way to achieve this?


Solution

  • I think that is a good approach. You can use the new psutil module to gather statistics, using it as cron job or a daemon, inserting the data into mongodb. Then use highcharts or something similar to display the data.

    Inserting to a capped collection in mongodb from psutil is just about as easy as save(), once you set up the db document structure to hold the data you're interested in.

    Here's a thread I just saw that shows how you could display it (you could use an ajax call to get the data from mongo instead of hardcoding like the example.

    http://lime-technology.com/forum/index.php?topic=29186.0;nowap