NLog.Targets.ClickHouse 1.1.0

dotnet add package NLog.Targets.ClickHouse --version 1.1.0
NuGet\Install-Package NLog.Targets.ClickHouse -Version 1.1.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="NLog.Targets.ClickHouse" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NLog.Targets.ClickHouse --version 1.1.0
#r "nuget: NLog.Targets.ClickHouse, 1.1.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.
// Install NLog.Targets.ClickHouse as a Cake Addin
#addin nuget:?package=NLog.Targets.ClickHouse&version=1.1.0

// Install NLog.Targets.ClickHouse as a Cake Tool
#tool nuget:?package=NLog.Targets.ClickHouse&version=1.1.0

NuGet NuGet downloads

NLog.Targets.ClickHouse

Implementation of ClickHouse target for Nlog.

Installation

Install-Package NLog.Targets.ClickHouse -Version 1.1.0

Example configuration:

The ClickHouse target works best together with the BufferingWrapper target applied.

<?xml version='1.0' encoding='utf-8' ?>
<nlog xmlns='http://www.nlog-project.org/schemas/NLog.xsd'
      xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
      internalLogToConsole='true'
      autoReload='true'>
    <targets>
        <target
                name='clickhouse_queue'
                xsi:type='BufferingWrapper'
                bufferSize='10000'
                flushTimeout='5000'
                overflowAction='Flush'>
            <target name='clickhouse'
                    xsi:type='ClickHouse'
                    connectionString='Host=localhost;Port=9000;Database=logs;User=sa;Password=P@ssw0rd;'
                    tableName='test'
                    batchSize='5000'>
                <install-command text="
                    CREATE TABLE IF NOT EXISTS test
                    (
                        logged DateTime64,
                        application String,
                        level LowCardinality(String),
                        message String,
                        logger String,
                        callSite String,
                        exception Nullable(String)
                    )
                    ENGINE Log" />
                <install-command text="TRUNCATE TABLE test" />
                <uninstall-command text="DROP TABLE IF EXISTS test" />
                <parameter name='application' dbType='String' layout='test_app'/>
                <parameter name='level' dbType='String' layout='${level}' />
                <parameter name='message' dbType='String' layout='${message}' />
                <parameter name='logger' dbType='String' layout='${logger}' />
                <parameter name='callSite' dbType='String' allowDbNull='true' layout='${callsite:filename=true}' />
                <parameter name='exception' dbType='String' allowDbNull='true' layout='${exception:tostring}' />
                <parameter name='logged' dbType='DateTime64' layout='${date}' />
            </target>
        </target>
    </targets>
    <rules>
        <logger name='*' minlevel='Trace' writeTo='clickhouse_queue' />
    </rules>
</nlog>

Development plans:

  • add internal queue in target to use instead of BufferedWrapper
  • improvements of default behavior;
  • initialization query feature to create or clean table and auto-create table support;
  • improvements and expansion of the config parameters list;
  • improved testing and benchmarking;

Special thanks

Many thanks to the authors of the implementations ClickHouse .NET client killwort/ClickHouse-Net and DarkWanderer/ClickHouse.Client. It was a challenge to choose which implementation to use.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.1.0 761 3/27/2022
1.0.0 404 3/1/2022