DapperLib / DapperLib/Dapper

Proposal: Built-in extensibility for structured logging (commands, parameters, connections, transactions)

Open
#2,201 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

Hi,

I'm currently looking for a robust way to implement logging with Dapper and would like to propose (or ask for guidance on) a more integrated/extensible approach.

Use case:

  • Log executed SQL statements including expanded parameters
  • Log connection lifecycle events (open/close), ideally with relevant (safe) metadata from the connection string
  • Optionally log transaction boundaries (begin/commit/rollback)
  • Ability to enable/disable logging easily (e.g. enabled in development/staging, disabled in production)

Problem:
I’ve experimented with wrapping DbConnection / DbCommand, but this tends to:

  • break or interfere with Dapper internals (e.g. list parameter expansion for IN (...))
  • become fragile and hard to maintain across different providers

Question / proposal:
Would it be possible to introduce an official extensibility point (e.g. interceptor, pipeline hook, or diagnostic listener) that allows:

  • inspecting the final command text + parameters as Dapper executes it
  • observing connection and transaction events without wrapping providers
  • plugging in logging in a clean, opt-in way

Something similar in spirit to logging/interception patterns in other ORMs would make this much easier and safer to implement.

I'm limited in knowledge to be able to contribute or help refine the design but I hope this is something that could fit within Dapper’s scope.

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by reviewing Dapper's command execution and connection/transaction handling paths, then check whether existing diagnostics or extension points cover them. Done would require a decided, opt-in design for command, connection, and transaction observation, including parameter handling and enable/disable behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend-api-design, databases, observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.