Similar to the “Log” in SQL, is there a similar command to print operations for MongoDB?
context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
Similar to the “Log” in SQL, is there a similar command to print operations for MongoDB?
context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
Hi @Nicholas_Vella,
Welcome to the MongoDB Community Forums. In order to print the DB operations in the log (like the MQL), you can use LogTo
with any logger such as Console.WriteLine
and EnableSentitiveDataLogging
to make sure you can see all fields in the database while creating your DbContext.
public static MflixDbContext Create(IMongoDatabase database) =>
new(new DbContextOptionsBuilder<MflixDbContext>()
.UseMongoDB(database.Client, database.DatabaseNamespace.DatabaseName)
.EnableSensitiveDataLogging()
.LogTo(Console.WriteLine)
.Options);
Hope that helps.
Thanks,
Rishit.
Thank you, I was able to get the information I needed.
Topic | Replies | Views | Activity |
---|---|---|---|
Referencing a document instead of including it and including it in a query in C# | 2 | 569 | Jun 2024 |
Error connecting to atlas ssl - TLS handshake failed: Failed certificate verification calling hello | 9 | 1.3k | Aug 2024 |
Filtering on array properties | 2 | 536 | Aug 2024 |
Unable to Connect Looker Studio to MongoDB Atlas Using Atlas SQL (Without Enabling BI Connector) | 4 | 145 | 12h |
MongoDB Go Driver 2.0 options.ArrayFilters seems to be gone | 3 | 81 | Jan 23 |