Logging Sql Query Text To Application Insights

Posts   
 
    
GraemeMuir
User
Posts: 6
Joined: 05-Mar-2021
# Posted on: 05-Mar-2021 01:50:39   

Hi

I am trying to log the sql query text to Application Insights, but I am having issues with logging too much information when I only want the query text.

I am running an ASP.Net website. Net Framework 4.6 and LLBLGen 5.3.4

I have set the DBProviderFactory to use the Microsoft.Data.SqlClient in the gloabal.asax

            SD.LLBLGen.Pro.ORMSupportClasses.RuntimeConfiguration.ConfigureDQE<SQLServerDQEConfiguration>(
                                    c => c.AddDbProviderFactory(typeof(Microsoft.Data.SqlClient.SqlClientFactory)));

Then I added the SqlServerDQE diagnostic switch into the System.Diagnostics node in the app.config

    <switches>
        <add name="SqlServerDQE" value="4" />
    </switches>

This is logging the query text to app insights but is also outputting Method Enter: and Method Exit: entries which I want to avoid to reduce any impact in a production environment.

I see in the documentation that ORMPlainSQLQueryExecution should just log the query but I haven't been able to determine how to configure it via the documentation as trying to add it in the diagnostics switches doesn't cause any data to be outputted to the trace.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 05-Mar-2021 09:21:41   

If you set ORMQueryExecution to level 3 you get the query executed. Is that enough?

Frans Bouma | Lead developer LLBLGen Pro