Skip to content
Rolf Kristensen edited this page Jul 2, 2025 · 7 revisions

Sends log messages to the remote instance of Graylog Server using Graylog Extended Log Format (GELF).

Platforms Supported: All - Requires nuget-package NLog.Targets.Network

This target inherits from the Network Target, and so it has also all the properties of the Network Target available. Using the GelfLayout to produce GELF JSON output.

Configuration Syntax

<targets>
  <target xsi:type="Gelf"
          name="String"
          address="Layout">
    <gelffield name="String" layout="Layout" /><!-- repeated -->
  </target>
</targets>

Read more about using the Configuration File.

Parameters

General Options

  • name - Name of the target.

Payload Options

  • layout - Instance of GelfLayout that is used to format log messages. Layout Default: GelfLayout

  • GelfHostName - Graylog Message Host-field. Default = ${hostname}

  • GelfShortMessage - Graylog Message Short-Message-field (Truncates when longer than 250 chars). Default = ${message}

  • GelfFullMessage - Graylog Message Full-Message-field. Default = ${message}

  • GelfFacility - Legacy Graylog Message Facility-field. Default = null

  • IncludeEventProperties - Include all properties from the log events. Default = true.

  • IncludeScopeProperties - Include all scope-properties from the ScopeContext. Default = false.

  • ExcludeEmptyProperties - Exclude null/empty properties. Default = false.

  • ExcludeProperties - Comma separated string with names which properties to exclude.

  • IncludeProperties - Comma separated string with names which properties to explicitly include.

  • GelfField

    • name - Required. The name of the JSON-key
    • layout - The layout for the JSON-value (Can be a nested JsonLayout)
  • encoding - Encoding to be used. Encoding Default: utf-8

  • newLine - Indicates whether to append newline at the end of log message. Boolean Default: False

  • lineEnding - Line Ending to be used if newLine is set to true. LineEndingMode Default: CRLF. Not used if newLine is false. Possible values:

    • CRLF - Carriage Return and Line Feed (ASCII 13, ASCII 10). (default)
    • CR - Carriage Return (ASCII 13).
    • LF - Line Feed (ASCII 10).
    • NULL - Null terminator (ASCII 0)
    • None - No end of line characters.
  • maxMessageSize - Maximum message size in bytes. Integer Default: 65000

  • onOverflow - Action that should be taken if the message-size is larger than maxMessageSize. Possible values:

    • Discard - Discard the entire message.
    • Error - Report an error.
    • Split - Split the message into smaller pieces (Default)

Connection Options

  • address - Network address. Layout The network address can be:

    • tcp://host:port - TCP (auto select IPv4/IPv6)
    • tcp4://host:port - force TCP/IPv4
    • tcp6://host:port - force TCP/IPv6
    • udp://host:port - UDP (auto select IPv4/IPv6)
    • udp4://host:port - force UDP/IPv4
    • udp6://host:port - force UDP/IPv6
    • http://host:port/pageName - HTTP using POST verb
    • https://host:port/pageName - HTTPS using POST verb
  • keepConnection - Indicates whether to keep connection open whenever possible. Boolean Default: True

  • connectionCacheSize - Size of the connection cache (number of connections which are kept alive). Integer Default: 5

  • maxConnections - Maximum current connections. 0 = no maximum. Integer Default: 16. Not used if keepConnection is true.

  • onConnectionOverflow - Action that should be taken when open connections are higher than limit maxConnections.

    Possible enum values:

    • Discard - Discard new messages when reaching limit (Default)
    • Grow - Send message and ignore limit
    • Block - Block until pending connections has been freed.
  • maxQueueSize - Maximum queue size for a single connection. 0 means no limit. Integer. Default: 10000

  • onQueueOverflow - Action that should be taken if pending queue of messages is larger than maxQueueSize.

    • Discard - Discard the entire message (Default)
    • Grow - Ignore limit and grow the queue.
    • Block - Block until queue is below limit.
  • KeepAliveTimeSeconds - Idle time before first TCP keep-alive probe is sent. Faster detection of stale TCP connections. Currently only implemented for TCP. Integer. Default: 0 (Disabled)

  • SendTimeoutSeconds - Waiting time before TCP socket send-operation fails with timeout error. Default wait forever when network cable unplugged and tcp-buffer becomes full. Integer. Default: 0 (Disabled)

  • NoDelay - Disable the delayed ACK timer, and avoid delay of 200 ms. Default = true.

  • sslProtocols - Enables SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. Invalid certificates are not supported. Possible values (combination allowed, comma separated):

    • None - No SSL/TLS is used
    • Default - Accepts Tls or Ssl3
    • Ssl2 - really not recommended
    • Ssl3 - not recommended
    • Tls - TLS 1.0
    • Tls11 - TLS 1.1
    • Tls12 - TLS 1.2
  • SslCertificateFile - Enables loading SSL certificate from local file, instead of injecting into operating system cache (Blank value means disable SSL certificate validation)

  • SslCertificatePassword - When password is needed for loading SSL certificate from local file using SslCertificateFile

Example

<?xml version="1.0" encoding="utf-8"?>
<nlog throwConfigExceptions="true">

  <targets>
    <target name="graylog" xsi:type="gelf" address="http://localhost:12201/gelf" />
  </targets>

  <rules>
    <logger name="*" minlevel="Trace" writeTo="graylog" />
  </rules>
</nlog>
Clone this wiki locally
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy