Microsoft.SqlServer.XEvent.XELite 2019.7.2.9

XELite is cross platform library to read XEvents from XEL files or live SQL streams.

Install-Package Microsoft.SqlServer.XEvent.XELite -Version 2019.7.2.9
dotnet add package Microsoft.SqlServer.XEvent.XELite --version 2019.7.2.9
<PackageReference Include="Microsoft.SqlServer.XEvent.XELite" Version="2019.7.2.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.SqlServer.XEvent.XELite --version 2019.7.2.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Introduction

XELite is cross platform library to read XEvents from XEL files or live SQL streams.

Getting Started

Using XELite to parse XEL files

static void OutputXELFile(string fileName)
{
	var xeStream = new XEFileEventStreamer(fileName);

	xeStream.ReadEventStream(
		() => {
			Console.WriteLine("Headers found");
			return Task.CompletedTask;
		},
		xevent => {
			Console.WriteLine(xevent);
			Console.WriteLine("");
			return Task.CompletedTask;
		},
		CancellationToken.None).Wait();
}

Using XELite to connect to live event session

Step 1: Create & start event session. For example:

CREATE EVENT SESSION [sample_session] ON SERVER 
ADD EVENT sqlserver.sql_statement_completed(
    ACTION(sqlserver.sql_text))
GO

ALTER EVENT SESSION [sample_session] ON SERVER 
	STATE = START
GO

Step 2: Implement the code to connect and read the events. Here is a sample:

static void OutputXELStream(string connectionString, string sessionName)
{
    var cancellationTokenSource = new CancellationTokenSource();

    var xeStream = new XELiveEventStreamer(connectionString, sessionName);

    Console.WriteLine("Press any key to stop listening...");
    Task waitTask = Task.Run(() =>
        {
            Console.ReadKey();
            cancellationTokenSource.Cancel();
        });

    Task readTask = xeStream.ReadEventStream(() =>
        {
            Console.WriteLine("Connected to session");
            return Task.CompletedTask;
        },
        xevent =>
        {
            Console.WriteLine(xevent);
            Console.WriteLine("");
            return Task.CompletedTask;
        },
        cancellationTokenSource.Token);


    try
    {
        Task.WaitAny(waitTask, readTask);
    }
    catch (TaskCanceledException)
    {
    }

    if (readTask.IsFaulted)
    {
        Console.Error.WriteLine("Failed with: {0}", readTask.Exception);
    }
}

Introduction

XELite is cross platform library to read XEvents from XEL files or live SQL streams.

Getting Started

Using XELite to parse XEL files

static void OutputXELFile(string fileName)
{
	var xeStream = new XEFileEventStreamer(fileName);

	xeStream.ReadEventStream(
		() => {
			Console.WriteLine("Headers found");
			return Task.CompletedTask;
		},
		xevent => {
			Console.WriteLine(xevent);
			Console.WriteLine("");
			return Task.CompletedTask;
		},
		CancellationToken.None).Wait();
}

Using XELite to connect to live event session

Step 1: Create & start event session. For example:

CREATE EVENT SESSION [sample_session] ON SERVER 
ADD EVENT sqlserver.sql_statement_completed(
    ACTION(sqlserver.sql_text))
GO

ALTER EVENT SESSION [sample_session] ON SERVER 
	STATE = START
GO

Step 2: Implement the code to connect and read the events. Here is a sample:

static void OutputXELStream(string connectionString, string sessionName)
{
    var cancellationTokenSource = new CancellationTokenSource();

    var xeStream = new XELiveEventStreamer(connectionString, sessionName);

    Console.WriteLine("Press any key to stop listening...");
    Task waitTask = Task.Run(() =>
        {
            Console.ReadKey();
            cancellationTokenSource.Cancel();
        });

    Task readTask = xeStream.ReadEventStream(() =>
        {
            Console.WriteLine("Connected to session");
            return Task.CompletedTask;
        },
        xevent =>
        {
            Console.WriteLine(xevent);
            Console.WriteLine("");
            return Task.CompletedTask;
        },
        cancellationTokenSource.Token);


    try
    {
        Task.WaitAny(waitTask, readTask);
    }
    catch (TaskCanceledException)
    {
    }

    if (readTask.IsFaulted)
    {
        Console.Error.WriteLine("Failed with: {0}", readTask.Exception);
    }
}

  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETStandard 2.0

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2019.7.2.9 176 7/2/2019
2019.6.5.2 171 6/5/2019
2019.5.24.2 160 5/24/2019