Paysky.ElasticLogger 1.0.0

Additional Details

This package has been replaced by Nazeh.ElasticLogger

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Paysky.ElasticLogger --version 1.0.0
                    
NuGet\Install-Package Paysky.ElasticLogger -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Paysky.ElasticLogger" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Paysky.ElasticLogger" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Paysky.ElasticLogger" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Paysky.ElasticLogger --version 1.0.0
                    
#r "nuget: Paysky.ElasticLogger, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Paysky.ElasticLogger@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Paysky.ElasticLogger&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Paysky.ElasticLogger&version=1.0.0
                    
Install as a Cake Tool

ElasticLogger

A reusable .NET library for configuring Serilog with Elasticsearch and Kibana integration.

Installation

dotnet add package Paysky.ElasticLogger

Usage

Option 1: Using Configuration File (appsettings.json)

{
  "ElasticLogger": {
    "ElasticsearchUri": "your domain",
    "ElasticsearchUsername": "elastic",
    "ElasticsearchPassword": "your-password",
    "IndexPrefix": "myapp-logs",
    "ApplicationName": "MyApplication",
    "Environment": "Production",
    "EnableConsoleLogging": true,
    "EnableFileLogging": true,
    "FileLogPath": "logs/myapp-.log",
    "RetainedFileCountLimit": 7,
    "BatchPostingLimit": 50,
    "PeriodSeconds": 2,
    "RequestTimeoutSeconds": 5,
    "BufferLogShippingIntervalSeconds": 5,
    "BufferBaseFilename": "./logs/buffer",
    "ValidateServerCertificate": false,
    "MinimumLogLevel": "Information"
  }
}
using ElasticLogger;
using Serilog;

var configuration = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .Build();

// In Program.cs
var host = Host.CreateDefaultBuilder(args)
    .UseSerilog()
    .ConfigureServices((ctx, services) =>
    {
        services.AddElasticLogger(ctx.Configuration);
        // Add other services
    })
    .Build();

await host.RunAsync();

Option 2: Using Code Configuration

using ElasticLogger;
using Serilog;

var host = Host.CreateDefaultBuilder(args)
    .UseSerilog()
    .ConfigureServices((ctx, services) =>
    {
        services.AddElasticLogger(options =>
        {
            options.ElasticsearchUri = "http://172.16.16.53:9200";
            options.ElasticsearchUsername = "elastic";
            options.ElasticsearchPassword = "your-password";
            options.IndexPrefix = "myapp-logs";
            options.ApplicationName = "MyApplication";
            options.Environment = "Production";
            options.EnableConsoleLogging = true;
            options.EnableFileLogging = true;
        });
        // Add other services
    })
    .Build();

await host.RunAsync();

Option 3: Direct Logger Creation

using ElasticLogger;
using Serilog;

Log.Logger = ElasticLoggerConfiguration.CreateLogger(options =>
{
    options.ElasticsearchUri = "http://172.16.16.53:9200";
    options.ElasticsearchUsername = "elastic";
    options.ElasticsearchPassword = "your-password";
    options.IndexPrefix = "myapp-logs";
    options.ApplicationName = "MyApplication";
});

Log.Information("Application started");

Configuration Options

Property Type Default Description
ElasticsearchUri string http://localhost:9200 Elasticsearch server URI
ElasticsearchUsername string elastic Elasticsearch username
ElasticsearchPassword string (empty) Elasticsearch password
IndexPrefix string app-logs Prefix for Elasticsearch indices
ApplicationName string Application Application name for log enrichment
Environment string Production Environment name for log enrichment
EnableConsoleLogging bool true Enable console output
EnableFileLogging bool true Enable file logging
FileLogPath string logs/app-.log File log path
RetainedFileCountLimit int 7 Number of log files to retain
BatchPostingLimit int 50 Elasticsearch batch size
PeriodSeconds int 2 Elasticsearch batch period
RequestTimeoutSeconds int 5 Elasticsearch request timeout
BufferLogShippingIntervalSeconds int 5 Buffer shipping interval
BufferBaseFilename string ./logs/buffer Buffer file location
ValidateServerCertificate bool false Validate SSL certificates
MinimumLogLevel string Information Minimum log level

Logging

using Serilog;

Log.Information("User logged in: {Username}", username);
Log.Warning("High memory usage detected");
Log.Error(exception, "Failed to process request");
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated