Using the Logging Application Block
- Last Updated: April 16, 2026
- 3 minute read
- ADO.NET
- Documentation
Applications that use the standard Logging Application Block (LAB) and Microsoft patterns and practices can quickly replay the SQL generated when using the DataDirect data providers for ADO.NET Entity Framework. The SQL logged to the Logging Block is the SQL that is ultimately transmitted to the application.
Recording the SQL emitted by the ADO.NET Entity Framework is useful for database administrators. In the current release, LAB support can be used for general logging of Errors, DbCommandTrees, SQL, and Parameters.
To use features of the Enterprise Library with your data provider, download the Microsoft Enterprise Library 6.0. The installation by default includes the documentation for the Enterprise Library 6.0. This documentation includes extensive information on using the Logging Application Block.
Note: Enterprise Library 6.0 requires Windows 8, or Windows 7, or Windows Server 2012, or Windows Server 2008 R2.
Configuring the Logging Application Block
To enable the DataDirect Connect logging features, you must configure the Logging Application Block. Refer to Logging Application Blocks in the DataDirect Connect Series for ADO.NET Reference for more information.
Before you add the Logging Application block to your application, open the Enterprise Library Configuration tool and ensure that the following categories are defined:
- DDTek Detailed Information: Enables SQL, Parameter, and DbCommandTree logging
- DDTek Error: Information related to errors
- DDTek Information: Information not related to errors
Using the Logging Application Block in Application Code
The LAB that you configured must be added to the app.config or web.config file for your application.
The following settings can be used to enable and configure the data provider's interaction with the LAB.
-
EnableLoggingApplicationBlock: Enables the Logging Application Block.
-
LABLoggerTypeName: Specifies the type name for the Logging Application Block.
-
LABLogEntryTypeName: Specifies the type name for the LogEntry object.
-
LABAssemblyName: Specifies the assembly name to which the Logging Application Block applies.
Note: If you are using any version of the LAB other than the Microsoft Enterprise Library 6.0 (April 2013) binary release, you must set the LABAssemblyName. For example, if you are using an older or newer version of the LAB, or a version that you have customized, you must specify a value for LABAssemblyName.
The following code fragment provides an example of a Logging Application Block that could be added to an Oracle data access application.
<loggingConfiguration name="Logging Application Block"
tracingEnabled="true"
defaultCategory="" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add fileName="rolling.log"
footer="----------------------------------------"
header="----------------------------------------"
rollFileExistsBehavior="Overwrite"
rollInterval="None" rollSizeKB="0"
timeStampPattern="yyyy-MM-dd"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Rolling Flat File Trace Listener" />
</listeners>
<formatters>
<add template="Message: {message}
Category: {category}
Priority: {priority}
EventId: {eventid}
Severity: {severity}
title:{title}

"
original_filename: tools.3.6.md
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="DDTek">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
Establishing a Listener for the Log
The Logging Application Block includes some trace listeners. In some cases, these listeners will not satisfy your application's requirements. In this case, you must create your own trace listeners.
Create a new class for the trace listener, and specify that it inherits from the CustomTraceListener class. Override the TraceData method to format the LogEntry object and write the information to the output destination.
After you configure the application to use the Logging Application Block, use the Enterprise Library configuration tools to create a new custom trace listener and specify your trace listener's type name and any other custom configuration properties. Create or modify existing categories to use the trace listener as a destination.
Refer to Logging Application Blocks the DataDirect Connect Series for ADO.NET Reference for information on configuring the application, and to the Microsoft Enterprise Library 6.0 documentation for additional information on using Logging Application Blocks.
When to Use the Logging Application Block
The DataDirect ADO.NET Entity Framework data providers include a set of LAB customizations that are useful for developing with the ADO.NET Entity Framework when you want to log the Command Trees and SQL generated when using the data provider.