-
Notifications
You must be signed in to change notification settings - Fork 89
Home
<targets>
<target xsi:type="ElasticSearch"
name="String"
uri="Layout"
index="Layout"
documentType="Layout"
includeDefaultFields="Boolean"
includeAllProperties="Boolean"
excludedProperties="String"
disableAutomaticProxyDetection="Boolean"
requireAuth="Boolean"
username="Layout"
password="Layout"
cloudId="Layout"
apiKeyId="Layout"
apiKey="Layout">
<field name="String" layout="Layout" layoutType="Type" /><!-- repeated, optional, if includeDefaultFields=true, you need to explicitly specify fields, otherwise, will use the properties found in the exception object -->
</target>
</targets>
-
name - Name of the target. String
-
uri - Uri of a Elasticsearch node. Multiple can be passed comma separated. Ignored if cloud id is provided. Layout Default: http://localhost:9200
-
index - Index to write to, if it doesn't exist it will be created. Layout Default: logstash-${date:format=yyyy.MM.dd}
-
documentType - Type of document. Layout Default: _doc
Version 7.2 (and older) used the default
logevent
but it has now been deprecated.When connecting to Elastic-Server 8.0 make sure to use
documentType=""
to avoid unknown parameter error. -
opCodeCreate (since version 7.5.0) - Change OpCode from the default
index
tocreate
for support of data-streams in Elastic 7.9 Boolean. Default: False -
fields - A collection of fields. Each field contains a mapping between a NLog layout and a named field.
-
includeDefaultFields (since version 7.6.0) - Always include the
<field>
for@timestamp
,level
,message
andexception
. Boolean Default: True -
includeAllProperties - Include LogEvent Properties captured from structured logging. Boolean Default: False
-
excludedProperties - Works with includeAllProperties to exclude specific properties. String
-
maxRecursionLimit (since version 7.2.0) - Limits how far the reflection will go down the object graph. Default: -1
- -1 = No limits without reference loop checking (Default - Can give stackoverflow/deadlock for complex objects)
- 0 = No reflection only perform object ToString
- 1 = Simple reflection where only direct properties are included.
- 2 = Full reflection but with checking of reference loops
-
enableJsonLayout (since version 7.3.0) - Provided own JsonLayout (Ex. EcsLayout), instead of relying on ElasticSearch.Net JsonSerialization. Boolean. Default: False
-
disableAutomaticProxyDetection (since version 2.0.5) - Optionally disable automatic proxy detection. Boolean
-
disablePing (since version 5.1.0) - Set it to true to disable use of ping to checking if node is alive. Boolean
-
enableHttpCompression (since version 5.1.0) - Set it to true to enable HttpCompression (Must be enabled on server). Boolean
-
disableCertificateValidation (since version 7.2.0) - Set it to true to disable SSL certificate validation. Boolean
-
pipeline (since version 5.1.0) -Optionally configure pipeline. Layout
-
proxyAddress (since version 7.2.0) - Optionally configure proxy address. Layout
-
proxyUserName (since version 7.2.0) - Optionally configure proxy login username. Layout
-
proxyPassword (since version 7.2.0) - Optionally configure proxy login password. Layout
-
requireAuth - Optionally enable basic authentication. Boolean Default: False
-
username - Username for basic authentication. Can also be used together with cloudId. Layout
-
password - Password for basic authentication. Can also be used together with cloudId. Layout
-
cloudId - (since version 7.1.1) Id for Elastic Cloud hosted deployment. Layout Default:
empty
-
apiKeyId - (since version 7.6.) - API key authentication for Elastic Cloud using
ApiKeyAuthenticationCredentials
. Layout -
apiKey - (since version 7.6.) - API key authentication for Elastic Cloud using
ApiKeyAuthenticationCredentials
. Layout
<target xsi:type="ElasticSearch">
<field name="mdlc" layoutType="System.Object">
<layout xsi:type="JsonLayout" includeMdlc="true" />
</field>
</target>
{
"ConnectionStrings": {
"ElasticUrl": "http://localhost:9200"
}
}
Can be extracted using ${configsetting} from NLog.Extensions.Logging nuget package:
${configsetting:item=ConnectionStrings.ElasticUrl}
<configuration>
<connectionStrings>
<add name="ElasticUrl" connectionString="http://localhost:9200"/>
</connectionStrings>
</configuration>
Can be extracted using ${appsetting} from when using NLog 4.6.5:
${appsetting:item=ConnectionStrings.ElasticUrl}
Skips reflecttion for System.Uri-types and instead just do object.ToString():
<target xsi:type="ElasticSearch">
<typeconverter objecttype="System.Uri, System.Private.Uri" />
</target>