Skip to content

A client library for Anexia CloudLog that provides a simple API for sending events to a CloudLog index directly from your .NET application.

License

Notifications You must be signed in to change notification settings

anexia/dotnet-cloudlog

Repository files navigation

dotnet-cloudlog

Nuget Test status

dotnet-cloudlog is a client library for Anexia CloudLog. It provides a simple API for sending events to a CloudLog index directly from your .NET application.

Note: Usually it is considered best-practice to write rotating log-files to the filesystem, and send those logs to CloudLog via Filebeat.

Install

With a correctly set up .NET SDK, run in PowerShell:

Install-Package Anexia.BDP.CloudLog

Getting started

Example 1

To send unstructured messages to the CloudLog index, use the code as follows:

using System.Net.Http;
using Anexia.BDP.CloudLog;var client = new Client("SomeIndex", "SomeToken");
var message = "Some message that you want to send to the CloudLog index";

client.PushEvent(message);

Example 2

To send structured messages to the CloudLog index, use the code as follows:

using System.Net.Http;
using Anexia.BDP.CloudLog;var client = new Client("SomeIndex", "SomeToken");
var message = "{\"message\":\"Something\",\"timestamp\":\"1669816693\"}"; // `timestamp` is a UNIX timestamp

client.PushEvent(message);

Example 3

HttpClient may be passed to the constructor to allow for modification of the HTTP requests, as shown in the code as follows:

using System.Net.Http;
using Anexia.BDP.CloudLog;var client1 = new Client("SomeIndex", "SomeToken", new HttpClient());
var client2 = new Client("SomeIndex", "SomeToken", HttpFactory.Create());

Example 4

The methods PushEvent and PushEvents return an awaitable PostAsync task, as shown in the code as follows:

using System;
using System.Net.Http;
using Anexia.BDP.CloudLog;var client = new Client("SomeIndex", "SomeToken");
var message = "Some message that you want to send to the CloudLog index";
var response = await client.PushEvent(message);

Console.WriteLine(response.StatusCode); // should print `201`

Supported versions

Supported
.Net 5.0
.Net 6.0
.Net 7.0

About

A client library for Anexia CloudLog that provides a simple API for sending events to a CloudLog index directly from your .NET application.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages