Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anexia/dotnet-cloudlog
A client library for Anexia CloudLog that provides a simple API for sending events to a CloudLog index directly from your .NET application.
https://github.com/anexia/dotnet-cloudlog
Last synced: 8 days ago
JSON representation
A client library for Anexia CloudLog that provides a simple API for sending events to a CloudLog index directly from your .NET application.
- Host: GitHub
- URL: https://github.com/anexia/dotnet-cloudlog
- Owner: anexia
- License: mit
- Created: 2018-01-15T09:14:17.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-07-09T21:38:42.000Z (7 months ago)
- Last Synced: 2024-11-17T16:11:51.819Z (2 months ago)
- Language: C#
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
dotnet-cloudlog
===============
[![Nuget](https://img.shields.io/nuget/v/Anexia.BDP.CloudLog)](https://www.nuget.org/packages/Anexia.BDP.CloudLog)
[![Test status](https://github.com/anexia/dotnet-cloudlog/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/anexia/dotnet-cloudlog/actions/workflows/test.yml)`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`:
```powershell
Install-Package Anexia.BDP.CloudLog
```# Getting started
## Example 1
To send unstructured messages to the CloudLog index, use the code as follows:
```cs
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:
```cs
using System.Net.Http;
using Anexia.BDP.CloudLog;…
var client = new Client("SomeIndex", "SomeToken");
var message = "{\"message\":\"Something\",\"timestamp\":\"1669816693\"}"; // `timestamp` is a UNIX timestampclient.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:```cs
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:```cs
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 | ✓ |