0

Looking at this similar question I need to do the same thing, that is I want the SQL to be copied to my Output, but I need it done for EF Core / 7

I tried adding the LogFactory as is shown in this example

But that did not produce the SQL output either... what am I missing?

2
  • Do you have your loggerFactory configured in Startup.cs? Commented Jan 29, 2017 at 4:28
  • Show me how to do it please... Commented Jan 30, 2017 at 4:01

2 Answers 2

1

The EF Core 1.1 example you linked to should work, assuming you have the following in your Configure method in your Startup.cs:

public void Configure(
    IApplicationBuilder application, 
    IHostingEnvironment environment, 
    ILoggerFactory loggerFactory) {

        loggerFactory
            .AddConsole(LogLevel.Debug)  // This will output to the console/terminal
            .AddDebug(LogLevel.Debug);   // This will output to Visual Studio Output window

        // Your additional configuration here...
}
Sign up to request clarification or add additional context in comments.

2 Comments

Just for other who came here with the same problem read out this article. As this answer is not very helpful, except @Matt has added only the scaffolded code.
But it answered his question :(
0

You can also install dotnet tools. The repository contains command-line tools for the .NET Core CLI.

Running dotnet watch run, debugs the application as well as showing you any sql queries that are executed.

I am coding with VS code and not 100% sure if it will work in Visual Studio.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.