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 |
---|---|---|---|
Lookup on IMongoQueryable - getting an IAggregateFluent from IMongoQueryable | 0 | 281 | Jul 2024 |
I issue with memory leaks after updating mongoDB driver | 0 | 414 | Aug 2024 |
how to deploy mongo pods in differnt zone’s while using mongodb-kubernetes-operator? | 0 | 34 | Sep 2024 |
BsonClassMapSerializer is now sealed in v3.0 | 1 | 52 | Oct 2024 |
LINQ3 ignors custom serializer if enum in expression has explicit type | 1 | 23 | 9d |