LoginSignup
8

More than 5 years have passed since last update.

MongoDBで実行したクエリをログに出力する

Last updated at Posted at 2016-04-20

実行環境

  • OS

    • Mac OS X
  • MongoDBのバージョン

    • 2.4.12

手順

MongoDB起動時に下記のオプションを付与
mongod --logpath=/usr/local/var/log/mongodb/mongo.log -profile=1 --slowms=-1
※logpathの場所は各自の設定に合わせること
※1ms以上のクエリのみ出力したい場合は--slowms=-1--slowms=1に変更する

任意のクエリを実行し、
tail -f /usr/local/var/log/mongodb/mongo.log
でログが出力されていることを確認する

参考リンク

MongoDBで実行クエリを必ずログに出力する方法
http://kakakikikeke.blogspot.jp/2014/09/mongodb-logging-query.html

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8