Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add verbose logging to System.Data.SQLite

Is it possible to add verbose logging to System.Data.SQLite ? I want to log all db operations such as connection opened/closed and all sql commands

like image 854
jacob Avatar asked Dec 07 '25 10:12

jacob


1 Answers

Yes, you can hook into the static Changed event on SQLiteConnection:

SQLiteConnection.Changed += (sender, eventArgs) =>
{
    Console.WriteLine($"{eventArgs.EventType}: {eventArgs.Text}");
};

This will print out lots of information. There are other properties on that eventArgs object as well.

like image 199
Lasse V. Karlsen Avatar answered Dec 10 '25 00:12

Lasse V. Karlsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!