Skip to content
Switch branches/tags
Go to file


An NLog Target For Loggly.

nlog-targets-loggly MyGet Build Status NuGet

Install via nuget with

Install-Package nlog.targets.loggly

See the Demo project in the solution for a working example. Be sure to create your own config file which is not included in the repo. Try something like this:

C:\nlog-targets-loggly> copy .\examples\Demo\example.loggly.user.config .\examples\Demo\loggly.user.config

Example Config

This NLog target project reads the loggly-csharp configuration, so be sure to add the Loggly config section as well as NLog config.

See below for sample NLog config (loggly config not shown).

<nlog xmlns="" xmlns:xsi=""  throwConfigExceptions="true">
	  <add assembly="NLog.Targets.Loggly" />
	<variable name="DefaultLayout" value="${longdate} | ${level:uppercase=true:padding=5} | ${message} | ${exception:format=type,tostring}" />

	<targets async="true">
	  <target name="ColorConsole" xsi:type="ColoredConsole" layout="${DefaultLayout}" />
	  <target name="Loggly" xsi:type="Loggly" layout="${message}" />
	  <logger name="*" minlevel="Info" writeTo="ColorConsole,Loggly" />

Loggly EndPoint Config

Loggly Config can be configured through the NLog Target properties:

<target name="Loggly" xsi:type="Loggly" layout="${message}" applicationName="MyApp" customerToken="your token" endpointHostname="" endpointPort="443" logTransport="https">

The following settings are supported:

  • CustomerToken - Required value, unless configured elsewhere
  • LogTransport - Loggly EndPoint Protocol (Https, SyslogUdp, SyslogTcp, SyslogSecure). Default = Https
  • EndpointHostname - Loggly EndPoint HostName. Default =
  • EndpointPort - Loggly EndPoint Port Number. Default = Value matching LogTransport
  • ApplicationName - Application Identifier. Default = AppDomain FriendlyName
  • ForwardedForIp - Include HTTP Header X-Forwarded-For. Default = Not set

Batching Policy

  • batchSize - Number of LogEvents to send in a single batch (Default=10)
  • taskDelayMilliseconds - Artificial delay before sending to optimize for batching (Default=200 ms)
  • queueLimit - Number of pending LogEvents to have in memory queue, that are waiting to be sent (Default=10000)
  • overflowAction - Action to take when reaching limit of in memory queue (Default=Discard)


Loggly Tags can be added like this:

<target name="Loggly" xsi:type="Loggly" layout="${message}">
  <tag name="{logger}" />


Loggly includes NLog LogEvent Properties automatically, but one can also add extra context like this:

<target name="Loggly" xsi:type="Loggly" layout="${message}">
  <contextproperty name="HostName" layout="${machinename}" />
  <contextproperty name="ThreadId" layout="${threadid}" />

MappedDiagnosticsLogicalContext (MDLC)

Loggly can also include async context from NLog MDLC (Contains state from NetCore ILogger.BeginScope)

<target name="Loggly" xsi:type="Loggly" layout="${message}" includeMdlc="true" />


Sometimes you might emit something to a flat file log that doesn't make sense in loggly, such as a delimiting line of dashes: ---------

Add a property to your nLog event with the name syslog-suppress to filter these out so they don't transmit to loggly.


NLog Target For Loggly



No packages published