NLog.Targets.Gelf is an [NLog] target implementation to push log messages to [GrayLog2]. It implements the [Gelf] specification and communicates with GrayLog server via UDP.
Code forked from https://github.com/ARSFI/NLog.Targets.Gelf
Here is a sample nlog configuration snippet:
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="NLog.Targets.Gelf"/>
</extensions>
<targets>
<!-- Other targets (e.g. console) -->
<target name="gelf"
xsi:type="gelf"
endpoint="udp://logs.local:12201"
facility="console-runner"
sendLastFormatParameter="true"
>
<!-- Optional parameters -->
<parameter name="param1" layout="${longdate}"/>
<parameter name="param2" layout="${callsite}"/>
</target>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="gelf" />
</rules>
</nlog>
Options are the following:
- name: arbitrary name given to the target
- xsi:type: set this to "gelf"
- endpoint: the uri pointing to the graylog2 input in the format udp://{IP or host name}:{port} note: support is currently only for udp transport protocol
- facility: The graylog2 facility to send log messages
- sendLastFormatParameter: default false. If true last parameter of message format will be sent to graylog as separate field per property