Closed ajcvickers closed 4 years ago
Is there a simpler way for logging (e.g. to console for debugging) other than the example described in #2795 by now?
Feel free to reuse my naive extension method here: https://github.com/ErikEJ/EntityFramework7.SqlServerCompact/blob/master/src/Provider40/Extensions/SqlCeDbContextExtensions.cs and here: https://github.com/ErikEJ/EntityFramework7.SqlServerCompact/tree/master/src/Provider40/Extensions/Logging
@leak - not yet, you still need to plug all the low level stuff together
BTW, just logging everything is relatively simple:
db.GetService<ILoggerFactory>().AddProvider(new ConsoleLoggerProvider());
@bricelam that needs to go in app startup right since the ServiceProvider is shared between context instances? Otherwise you add it multiple times.
Hmm yes, I think you're right...
FYI http://docs.efproject.net/en/latest/miscellaneous/logging.html shows how to achieve the same thing before we have full support for this feature
Need to re-triage this. The state of logging right now means that many people will have to use an obsolete API in logging to get logs from EF. We should decide whether to try to do something here for RTM.
Note: #8350 has been moved to the backlog. It should be re-triaged after this work is done.
Note: See #12183. Make sure that simple logging it attached before the internal service provider has been built.
Having fallen foul of of using the obsolete logging API (#12183) can I give feedback on the two use cases where getting access to logs for a specific DbContext. Or alternatively being able to identify logs for a specific DbContext out of all the logs.
You may have a solution to these that I have missed. If so please let me know.
This would make use of the core logging services without the need to do any wire-up.
We may want a
Database.Log
for SQL and then something likeContext.Log
for everything.