Support for Configuring Npgsql Tracing Options in NHibernate
I am using NHibernate with PostgreSQL via the Npgsql driver in our application. We are aiming to configure tracing options in Npgsql to control and eliminate specific logs emitted by Npgsql, particularly to improve our logging output and reduce noise.
The latest version of Npgsql introduces the ability to configure tracing options using the NpgsqlDataSourceBuilder API, as detailed in the Npgsql documentation:
Npgsql Tracing Documentation However, I have encountered an issue where NHibernate's NpgsqlDriver does not seem to support configuring these tracing options. It appears that NHibernate uses NpgsqlConnection directly to create connections, without exposing a way to utilize NpgsqlDataSource or configure the tracing options.
My Questions:
- Is there a way to configure Npgsql tracing options within NHibernate?
- Can we extend or customize the NpgsqlDriver or ConnectionProvider to use NpgsqlDataSource and apply tracing configurations?
- Are there plans to update NHibernate to support the latest Npgsql features, including the NpgsqlDataSource API?
DbDataSource is a very new concept and it's not necessarily a good fit for NHibernate (support is slim in EF too), so it's unfortunate that tracing options can only be configured that way. That said, it would certainly be possible to create a custom driver which uses NpgsqlDataSource.
For an example of a custom driver (but not using a datasource), you can see this project.
I recently implemented NpgsqlDataSourceConnectionProvider using NpgsqlDataSourceBuilder: https://github.com/npgsql/npgsql/issues/6021#issuecomment-2665157145 Hope it might help.