Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
How to: Enable Tracing and Logging
See Also
Programmer's Guide > OpenAccess ORM Classic (Old API) > OpenAccess Tasks > How to: Enable Tracing and Logging

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

Telerik OpenAccess ORM enables you to trace and log events generated by the OpenAccess ObjectScope. You can enable that feature in just a few steps. The purpose of this tutorial is to show you how to perform that task. 

In order to enable the Tracing and Logging:

  1. Open your project.
  2. From the Telerik menu, point OpenAccess, then Configuration, and then select Backend Configuration Settings.
  3. The Backend Configuration dialog appears.
  4. Set the Write events to text file to True.
  5. Specify the Log file name setting.
  6. Finally you need to set the Log Level option. The LogLevel setting serves as a filter - which statements will be written to the output file, and which won't. Note that if you set the LogLevel to all, then all events will be logged (this slows down the performance very significantly, could be used while debugging). LogLevel.Normal will log the most useful events that do not reduce performance significantly (e.g. SQL executed). LogLevel.Error will log only serious errors (such as connections timing out). LogLevel.None is the default value.
  7. Click OK to commit the changes.
  8. Build and run your application.
  9. In the following demonstration the LogLevel is set to all. A new instance of the ObjectScope is created and all categories from the Northwind database are printed.
    C# Copy Code
    IObjectScope objectScope = ObjectScopeProvider1.ObjectScope();
    foreach ( Category category in objectScope.Extent<Category>() )
    {
       Console.WriteLine( category.CategoryName );
    }
    The content of the output log file should be similar to this:
    Log File Copy Code
    20100729 13:50:49 PM pmf.start                  Log Level: all
    20100729 13:50:49 PM configuration              Resolving connection with id='NorthwindDbConnection'
    20100729 13:50:49 PM configuration              Config file=(.NET application config file)
    20100729 13:50:49 PM configuration              Check <openaccess> node
    20100729 13:50:49 PM configuration              Found connection node with id='NorthwindDbConnection'
    20100729 13:50:49 PM configuration              Connection node is not empty
    20100729 13:50:49 PM configuration              Found connection string 'Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True'.
    20100729 13:50:49 PM configuration              Application configured connection string 'data source=.\SQLEXPRESS;initial catalog=Northwind;integrated security=True'.
    20100729 13:50:49 PM configuration              Application configured provider 'System.Data.SqlClient'
    20100729 13:50:49 PM configuration              Found backendconfigurationname='mssqlConfiguration'
    20100729 13:50:49 PM configuration              Resolving backendconfiguration id='mssqlConfiguration'
    20100729 13:50:49 PM configuration              Found backendconfiguration in (.NET application config file)
    20100729 13:50:49 PM configuration              Found in
    <openaccess> node
    20100729 13:50:49 PM configuration              Resolving connection with id='NorthwindDbConnection'
    20100729 13:50:49 PM configuration              Config file=(.NET application config file)
    20100729 13:50:49 PM configuration              Check
    <openaccess> node
    20100729 13:50:49 PM configuration              Found connection node with id='NorthwindDbConnection'
    20100729 13:50:49 PM configuration              Connection node is not empty
    20100729 13:50:49 PM configuration              Found connection string 'Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True'.
    20100729 13:50:49 PM configuration              Application configured connection string 'data source=.\SQLEXPRESS;initial catalog=Northwind;integrated security=True'.
    20100729 13:50:49 PM configuration              Application configured provider 'System.Data.SqlClient'
    20100729 13:50:49 PM configuration              Found backendconfigurationname='mssqlConfiguration'
    20100729 13:50:49 PM configuration              Resolving backendconfiguration id='mssqlConfiguration'
    20100729 13:50:49 PM configuration              Found backendconfiguration in (.NET application config file)
    20100729 13:50:49 PM configuration              Found in
    <openaccess> node
    20100729 13:50:49 PM driver.con.connect         MultipleActiveResultSets=true;Pooling=false;Enlist=false;data source=.\SQLEXPRESS;initial catalog=Northwind;integrated security=True
    20100729 13:50:50 PM driver.con.connect         MultipleActiveResultSets=true;Pooling=false;Enlist=false;data source=.\SQLEXPRESS;initial catalog=Northwind;integrated security=True
    20100729 13:50:50 PM driver.con.isolation       62258301 READ_COMMITTED(2)
    20100729 13:50:50 PM driver.con.autoCommit      62258301 false
    20100729 13:50:50 PM driver.pool.alloc          active=1/10 idle=0/10 HP con=62258301
    20100729 13:50:50 PM driver.con.rollback        62258301
    20100729 13:50:50 PM driver.pool.release        active=0/10 idle=1/10 con=62258301
    20100729 13:50:50 PM pm.created
  10. All Logging settings are stored in the Backend Configuration section of your App.config file. You could open your App.config file and locate the Backend Configuration section.
    XML Copy Code
    <backendconfigurations>
     
    <backendconfiguration id="mssqlConfiguration" backend="mssql">
       
    <mappingname>mssqlMapping</mappingname>
       
    <logDownloader.filename>C:\\MyLog</logDownloader.filename>
       
    <logging.logEvents>all</logging.logEvents>
       
    <logDownloader.eventText>True</logDownloader.eventText>
     
    </backendconfiguration>
    </
    backendconfigurations>

See Also