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 |
---|---|---|---|
“No suitable servers found” with laravel-mongodb | 2 | 812 | Aug 2024 |
As of v2.23.0, Expressions accessing Dictionary.Keys are no longer supported via IndexKeysDefinitionBuilder | 4 | 747 | Jun 2024 |
Casting IMongoQueryable<T> to IMongoQuerable<TInterface> | 0 | 249 | Jul 2024 |
Understanding transactions in Scala | 4 | 65 | Dec 2024 |
MongoDB Go Driver 2.0 options.ArrayFilters seems to be gone | 3 | 82 | Jan 23 |