title: mongodb user logs storage best practice
body: <p>I'm new to mongoDB and trying to figure out what would be the best way to store user logs. I identified two main solutions, but can't figure out which might be the best. If others come to mind, please feel free to share them ;)</p>
  
  <p>1)The first is about storing a log in all the collections that I have. For instance, If I have the 'post', 'friends', 'sports' and 'music' collections, then I could create a log field in each document in each collection with all the logging info that I want to store.</p>
  
  <p>2)The second way is to create an entire 'log' collection, each document having a type ('post', 'friends' ...) to identify the kind of log I'm storing along with the id of the document that is refered to.</p>
  
  <p>What I really need is to be able to store and retrieve data (that is, everything but logs) as fast as possible. (so if I go with (1), I would have to always remove the logs from my selection queries since they would be useless most of the time)
  Logs will only be accessed periodicaly (for reporting and stats mostly), yet will require to be mapped to their initial document (in case of (2)).
  I will be creating logs for almost all the non log data to store (so storing logs inside each collection might be faster : one insert vs two).
  Logging could also be done asynchronously to ease the load on the server.</p>
  
  <p>With all that in mind, I can't really manage to find which is the best for my needs. Would anyone have any idea / comments to share ?</p>
  
  <p>Thanks a lot !</p>