corelibraries-devexpress-dot-xpo-dot-db-e250c5b8.md
Enables operations performed by a specific IDataStore object to be logged.
Namespace : DevExpress.Xpo.DB
Assembly : DevExpress.Data.v25.2.dll
NuGet Package : DevExpress.Data
public class DataStoreLogger :
DataStoreSerialized,
ICommandChannel,
ICommandChannelAsync
Public Class DataStoreLogger
Inherits DataStoreSerialized
Implements ICommandChannel,
ICommandChannelAsync
The DataStoreLogger class allows you to log data-aware operations performed by a specific IDataStore object (for instance, for debug purposes). The IDataStore object, whose operations should be tracked, must be passed to the DataStoreLogger constructor.
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());
}
}
Imports System.IO
Imports DevExpress.Xpo
Imports DevExpress.Xpo.DB
Shared Sub Main()
Dim writer As StreamWriter = New StreamWriter("myLog.log")
Try
' Get the default connection provider.
' All the operations performed by this provider will be logged.
Dim trackedDataStore As IDataStore = _
XpoDefault.GetConnectionProvider(AutoCreateOption.DatabaseAndSchema)
' Create a logger that will track the default provider's behavior.
Dim logger As 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())
Finally
writer.Close()
End Try
End Sub
Object MarshalByRefObject DevExpress.Xpo.DB.DataStoreSerializedBase DevExpress.Xpo.DB.DataStoreSerialized DataStoreLogger
See Also