10

is there a way to log all linq2DB sql queries that are made to he database with NLog?

I cannot find any realistic example. There is something for miniprofiler, but this doesn't help me, because I have not experience with it.

pull request

example

example 2

Julian
  • 33,915
  • 22
  • 119
  • 174
Franki1986
  • 1,320
  • 1
  • 15
  • 40

1 Answers1

20

Inside your Setup method you could turn on Trace and setup WriteTraceLine to Console.WriteLine

[SetUp]
public void Setup()
{
    LinqToDB.Data.DataConnection.TurnTraceSwitchOn();
    LinqToDB.Data.DataConnection.WriteTraceLine = (message, displayName) => { Console.WriteLine($"{message} {displayName}"); };
}

This will write all executed SQL Queries (together with params) to the Console

Guru Stron
  • 102,774
  • 10
  • 95
  • 132
croban
  • 387
  • 2
  • 7