1

Log the MongoDb queries that are executed based on the business logic into console or log file.

ASP.NET Core, Mongo client, Mongo DB, LINQ.

I want this to understand how my queries are translated and executed in MongoDB. This will help fix performance issues, if any.

3
  • 1
    Have you looked at database auditing? Commented Apr 26, 2024 at 21:42
  • What did you try to achieve your goal? Did you try to google it up? If yes, what have you found so far? Commented Apr 27, 2024 at 22:13
  • Did you use any ORM package inside your project to query the database? If you have, which one? Commented May 2, 2024 at 9:02

1 Answer 1

1

See my answer here. In 2 words, you can subscribe on driver events, in particular CommandStartedEvent will contain information about sent commands to the server.

Also, you can use query analyzer plugin for the driver that will allow you to see queries that will be sent to the server just in VS notes: enter image description here

As additional approach, there is an option to use ILogger impls, you can find details here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.