How do I "tell" EF
to log queries globally? I was reading this blog post: EF logging which tells in general how to log sql
queries. But I still have a few questions regarding this logger.
- Where would I need to place this line
context.Database.Log = s => logger.Log("EFApp", s);
? - Can it be globally set? Or do I have to place it everywhere I do DB operations?
In the "Failed execution" section, the blogger wrote that, and I quote:
For commands that fail by throwing an exception, the output contains the message from the exception.
Will this be logged too if I don't use the context.Database.Log
?
I don't recommend to use that's functionality, because, it hasn't reason to exists in the real case. Thats it use a lot of to debug code only. But, wether you wanna know more than details ... access link... https://cmatskas.com/logging-and-tracing-with-entity-framework-6/ In this case you can put code like this
I hope thats useufull