Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Profiler #64

Closed
matthewjcooper opened this issue Sep 22, 2016 · 4 comments
Closed

SQL Profiler #64

matthewjcooper opened this issue Sep 22, 2016 · 4 comments

Comments

@matthewjcooper
Copy link

Can anyone recommend a way that i can see the actual complete sql statement that is sent to mysql with this library? The debug logger is outputting the query wit the parameters, but it shows the actual parameter values as ? like below. I'm trying to debug some issues with date parameters and need to see the exact parameter value that mysql is receiving. Thanks!

Executed DbCommand (3,887ms) [Parameters=[@__utcDate_0='?', @__AddDays_1='?', @__viewModel_LastName_2='?' (Size = 8000), @__viewModel_BirthDate_Date_3='?', @__AddDays_4='?'], CommandType='Text', CommandTimeout='30']

@caleblloyd
Copy link
Contributor

I know this is a hack, but you can use Wireshark to see what exactly gets sent to the database.

The reason you see parameterized logging in the ? format is because the Database Driver is using Prepared Statements. Prepared Statements escape parameters on the DBMS and prevent SQL Injection. The statement is actually sent to the DBMS with the ? marks, and the parameters are sent separately.

@caleblloyd
Copy link
Contributor

1.1.0-rtm-10002 now includes statement logging when Debug or Info logs are used in .NET MVC

@xland
Copy link

xland commented Mar 30, 2017

I cann't find the statement logging.

startup.cs Configure method:
loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug();

appsetting.json
"Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug" } }

version:
1.1.1-prerelease-10020

@caleblloyd

@mguinness
Copy link
Collaborator

Please note that you need to use EnableSensitiveDataLogging() to see actual parameter values when configuring the context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants