Skip to main content

DataStoreLogger(IDataStore, TextWriter) Constructor

Initializes a new instance of the DataStoreLogger class with the specified settings.

Namespace: DevExpress.Xpo.DB

Assembly: DevExpress.Data.v24.2.dll

Declaration

public DataStoreLogger(
    IDataStore nestedProvider,
    TextWriter logWriter
)

Parameters

Name Type Description
nestedProvider IDataStore

A IDataStore object that represents a tracked data store.

logWriter TextWriter

A TextWriter object that will log data-aware operations performed on the tracked data store

Example

The following example demonstrates how to log operations performed by a specific connection provider. To log operations, a new instance of the DataStoreLogger class is used. The operations are logged in a “myLog.log” file.

using System.IO;
using DevExpress.Xpo;
using DevExpress.Xpo.DB;

static void Main() {         
   using(StreamWriter writer = new StreamWriter("myLog.log")) {
      // Get the default connection provider. 
      // All the operations performed by this provider will be logged.
      IDataStore trackedDataStore = 
        XpoDefault.GetConnectionProvider(AutoCreateOption.DatabaseAndSchema);
      // Create a logger that will track the default provider's behavior.
      DataStoreLogger logger = new DataStoreLogger(trackedDataStore, writer);
      // Create a data layer and bind it to the logger. 
      // Assign it to the XPODefault.DataLayer.
      // A Session will then use this data layer(and so a logger) 
      // when a connection to a data store should be established.
      XpoDefault.DataLayer = new SimpleDataLayer(logger);
      Application.Run(new Form1());
   }
}
See Also