NLog Target for OpenSearch
This NLog target is designed to specifically work with OpenSearch Versions >=1.0. It is focused on performance, and doesn't require any third party clients.
Install the Nuget package
dotnet add package SocketLabs.NLog.Targets.OpenSearchInstall-Package SocketLabs.NLog.Targets.OpenSearch<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Warn" internalLogFile="logs/nlog-internal.log">
<extensions>
<add assembly="SocketLabs.NLog.Targets.OpenSearch"/>
</extensions>
<targets>
<target xsi:type="OpenSearch"
name="opensearch"
uris="http://localhost:9200"
username="logstash"
password="Pa$$w0rd!"
includeEventProperties="true"
includeCallSite="true"
includeCallSiteStackTrace="true"
includeScopeProperties="true"
enableHttpCompression="false"
validateCertificates="false">
<contextproperty name="appDomain" layout="${appdomain:format={1\}}" />
<contextproperty name="assemblyVersion" layout="${assembly-version}" />
<contextproperty name="dotnet.version" layout="${environment:DOTNET_VERSION}" />
<contextproperty name="gc.collectionCount0" layout="${gc:property=CollectionCount0}" />
<contextproperty name="gc.collectionCount1" layout="${gc:property=CollectionCount1}" />
<contextproperty name="gc.collectionCount2" layout="${gc:property=CollectionCount2}" />
<contextproperty name="gc.maxGeneration" layout="${gc:property=MaxGeneration}" />
<contextproperty name="gc.totalMemory" layout="${gc:property=TotalMemory}" />
<contextproperty name="gc.totalMemoryForceCollection" layout="${gc:property=TotalMemoryForceCollection}" />
<contextproperty name="hostname" layout="${hostname}" />
<contextproperty name="process.handleCount" layout="${processinfo:property=HandleCount}" />
<contextproperty name="process.maxWorkingSet" layout="${processinfo:property=MaxWorkingSet}" />
<contextproperty name="process.minWorkingSet" layout="${processinfo:property=MinWorkingSet}" />
<contextproperty name="process.name" layout="${processname}" />
<contextproperty name="process.peakWorkingSet64" layout="${processinfo:property=PeakWorkingSet64}" />
<contextproperty name="process.pid" layout="${processinfo:property=Id}" />
<contextproperty name="process.privateMemorySize64" layout="${processinfo:property=PrivateMemorySize64}" />
<contextproperty name="process.startTime" layout="${processinfo:property=StartTime}" />
<contextproperty name="process.virtualMemorySize64" layout="${processinfo:property=VirtualMemorySize64}" />
<contextproperty name="process.workingSet64" layout="${processinfo:property=WorkingSet64}" />
<contextproperty name="threadId" layout="${threadid}" />
<contextproperty name="system.environment" layout="${systemEnvironment}" />
<contextproperty name="kubernetes.namespace" layout="${environment:KUBERNETES_NAMESPACE}" />
</target>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="opensearch" />
</rules>
</nlog>- Visual Studio or VSCode
- .NET 7
- 1.0.0 Initial Release
This code base is licensed under the MIT License.