0

I have a legacy code that is using dapper's QueryAsync() on DbContext's dbconnection:

var connection = _context.GetConnection();
await connection.QueryAsync<Guid>(query, parameters);

How do I enable logging? Ideally I would like also SQL Dependencies to be logged as well (ApplicationInsights).

1 Answer 1

1

Dapper doesn't have additional inbuilt logging because usually (there are a few niche exceptions), what gets executed is exactly what you pass as query, making it possible for you to add your own logging wherever and however you like.

If you want general SQL-connection level logging i.e. of all SQL operations: MiniProfiler has DbConnection wrappers that offer that capability (or you could use the MiniProfiler implementation as a base to write your own).

Sign up to request clarification or add additional context in comments.

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.