Skip to content
Switch branches/tags
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

.NET Client for Loggly

Build status Version

A .NET client for loggly. Supporting Https, Syslog UDP and encrypted Syslog TCP transports. Install via nuget with

Install-Package loggly-csharp


This project supports .NET standard and so requires the latest tooling installed

Configuration via app.Config

Configuration may be done via your app.config. The minimal amount config you require is to specify your customerToken:

    <section name="loggly" type="Loggly.Config.LogglyAppConfig, Loggly.Config"/>
  <loggly xmlns="Loggly" customerToken="your token here" />

When you get that working, take the training wheels off and go crazy:

  customerToken="your token here" 

  <transport logTransport="Https" endpointHostname="" endpointPort="443"/>

  <search account="your_loggly_account" username="a_loggly_username" password="myLittleP0ny!"/>

      <tag value="winforms"/>
      <tag type="Loggly.HostnameTag" formatter="host-{0}"/>
      <tag type="Loggly.ApplicationNameTag" formatter="application-{0}"/>
      <tag type="Loggly.OperatingSystemVersionTag" formatter="os-{0}"/>
      <tag type="Loggly.OperatingSystemPlatformTag" formatter="platform-{0}"/>

Configuration via Code

The following sample shows how to configure loggly via code - useful for Azure/Asp.NET core scenarios. Be sure to do this very early in the application life cycle in order to capture your early logs.

var config = LogglyConfig.Instance;
config.CustomerToken = "1ceb00da-cec7-45cb-8135-d3adbeef";
config.ApplicationName = $"MyApp-{_environmentName}";

config.Transport.EndpointHostname = "";
config.Transport.EndpointPort = 443;
config.Transport.LogTransport = LogTransport.Https;

var ct = new ApplicationNameTag();
ct.Formatter = "application-{0}";


To set a global proxy for WebRequests used by HTTPS, you can do something like

System.Net.WebRequest.DefaultWebProxy = new WebProxy("");

Configuration Detail


This is an optional attribute. If you leave this attribute out but have NewRelic.AppName in your app.config, then it will pick that value up automatically. Render your application name as a tag by using the HostnameTag (keep reading).


Set it to false on your development machine so that no events are sent to loggly.


Three different transports may be specified with the logTransport attribute in the transport element. The transport element is entirely optional and will default to the Https. The available transports are as follows:


The default transport, posting to Loggly on port 443. Note that application and host source group filtering are not supported by HTTP, so you may wish to consider a Syslog transport.


If you specify an applicationName in the config, the syslog UDP transport will populate the field so it may be filtered in a source group. Host is also automatically populated by the client. Udp messages are sent in plain text.


Uses Syslog over TCP but is not encrypted. Note this needs to be on port 514 for loggly. Port 514 will be selected if not specified.


Transmits using syslog messages via a secure TLS TCP channel so that your logs are encrypted over the wire. Syslog supports JSON formatted messages just like Https. Port 6514 is required for loggly and will be the default if not specified.


When using remote logging from a desktop application, Loggly will record the IP of the machine transmitting logs (HTTP). This may represent PII (Personally Identifiable Information) and may not be desired. In order to override the value Loggly records, you may add the ForwardedForIp property to the Transport object's configuration with a dummy value (such as All messages sent to Loggly with record this Ip in the indexed clientHost property. The property allows for any string, but only a valid IP value will replace the indexed value at Loggly.


simple tags are string literals added to the app.config. What you see is what you get.

complex tags inherit from ComplexTag. They have the formatter attribute so you may specify your own string.Format. The Assembly attribute is available as an optional parameter so you can roll your own tags too.

Loggly has certain restrictions around characters allowed in tags. This library automatically replaces illegal characters with an underscore.

Usage: LogglyClient

Send simple text messages with something like this.

ILogglyClient _loggly = new LogglyClient();
var logEvent = new LogglyEvent();
logEvent.Data.Add("message", "Simple message at {0}", DateTime.Now);

Or log an entire object and let the client send it as structured JSON

logEvent.Data.Add("context", new GlimmerWingPony());

The Log method returns Task<LogResponse> so it is asynchronous by default but can be awaited. Only the Https transport would be worth awaiting as the Syslog transports are fire and forget.

Usage: SearchClient

See example project below in conjunction with the loggly docs

Loggly.Example Project

The solution has an example project with sample code to demonstrate the client. Before starting, copy the example config into the user config, eg:

C:\loggly-csharp>copy .\source\Loggly.Example\example.loggly.user.config .\source\Loggly.Example\loggly.user.config

And configure the file with your own customer token.

Of course, there is no need to have a config source in your real app, this is just a convenience for this public repository.


Contributions are welcome.

  • Open an issue to discuss your proposed changes
  • Branch your PR from the develop branch
  • .\build.ps1 is compatible with myget and appveyor build services for dogfooding your modifications
  • .\build.ps1 / Visual Studio 2015 will require VS2015 command prompt / .NET core tooling to compile the solution

Projects using this client



  • .NET Standard / Core compatible


  • Bug fixes for syslog transports


  • Targets framework 4.5
  • Log method returns Task<LogResponse> for async/await compatibility


  • New maintainer neutmute
  • Refactored API with new Config assembly
  • Syslog UDP and TCP support added

v2.0 and prior