CorentinAltepe.NLog.Loki 1.2.0

Suggested Alternatives

NLog.Targets.Loki

Additional Details

This package was renamed to NLog.Targets.Loki. Please use NLog.Targets.Loki to continue getting new features and fixes.

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 CorentinAltepe.NLog.Loki --version 1.2.0
                    
NuGet\Install-Package CorentinAltepe.NLog.Loki -Version 1.2.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="CorentinAltepe.NLog.Loki" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CorentinAltepe.NLog.Loki" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="CorentinAltepe.NLog.Loki" />
                    
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 CorentinAltepe.NLog.Loki --version 1.2.0
                    
#r "nuget: CorentinAltepe.NLog.Loki, 1.2.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 CorentinAltepe.NLog.Loki@1.2.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=CorentinAltepe.NLog.Loki&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=CorentinAltepe.NLog.Loki&version=1.2.0
                    
Install as a Cake Tool

NLog Loki Target

CI NuGet codecov

This is an NLog target that sends messages to Loki using Loki's HTTP Push API.

Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus. It is designed to be very cost effective and easy to operate.

Installation

The NLog.Loki NuGet package can be found here. You can install it via one of the following commands below:

NuGet command:

Install-Package CorentinAltepe.NLog.Loki

.NET Core CLI command:

dotnet add package CorentinAltepe.NLog.Loki

Usage

Under .NET Core, remember to register NLog.Loki as an extension assembly with NLog. You can now add a Loki target to your configuration file:

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  
  <extensions>
    <add assembly="NLog.Loki" />
  </extensions>

  
  <targets>
    <target 
      name="loki" 
      xsi:type="loki"
      batchSize="200"
      taskDelayMilliseconds="500"
      endpoint="http://localhost:3100"
      username="myusername"
      password="secret"
      orderWrites="true"
      layout="${level}|${message}${onexception:|${exception:format=type,message,method:maxInnerExceptionLevel=5:innerFormat=shortType,message,method}}|source=${logger}">
      
      <label name="app" layout="my-app-name" />
      <label name="server" layout="${hostname:lowercase=true}" />
    </target>
  </targets>

  <rules>
    <logger name="*" minlevel="Info" writeTo="loki" />
  </rules>

</nlog>

endpoint must resolve to a fully-qualified absolute URL of the Loki Server when running in a Single Proccess Mode or of the Loki Distributor when running in Microservices Mode.

username and password are optional fields, used for basic authentication with Loki.

orderWrites - Orders the logs by timestamp before sending them to loki when logs are batched in a single HTTP call. This is required if you use Loki v2.3 or below. But it is not required if you use Loki v2.4 or above (see out-of-order writes). You are strongly advised to set this value to false when using Loki v2.4+ since it reduces allocations by about 20% by the serializer (default true).

label elements can be used to enrich messages with additional labels. label/@layout support usual NLog layout renderers.

Async Target

NLog.Loki is an async target. You should not wrap it in an AsyncWrapper target. The following configuration options are supported. Make sure to adjust them to the expected throughput and criticality of your application's logs, especially the batch size, retry count and task delay.

taskTimeoutSeconds - How many seconds a Task is allowed to run before it is cancelled (default 150 secs).

retryDelayMilliseconds - How many milliseconds to wait before next retry (default 500ms, and will be doubled on each retry).

retryCount - How many attempts to retry the same Task, before it is aborted (default 0, meaning no retry).

batchSize - Gets or sets the number of log events that should be processed in a batch by the lazy writer thread (default 1).

taskDelayMilliseconds - How many milliseconds to delay the actual write operation to optimize for batching (default 1 ms).

queueLimit - Gets or sets the limit on the number of requests in the lazy writer thread request queue (default 10000).

overflowAction - Gets or sets the action to be taken when the lazy writer thread request queue count exceeds the set limit (default Discard).

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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.
  • net6.0

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