Collect logs from your .NET projects using NLog.
We wrote a tutorial on how to use NLog. We recommend reading it first if you're not familiar with NLog.
  1. 1.
    Install the Logtail NuGet package: dotnet add package Logtail
  2. 2.
    Add an extension, target, and rule to your nlog.config like this:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
<add assembly="Logtail" />
<target xsi:type="Logtail" name="logtail" sourceToken="YOUR_SOURCE_TOKEN" />
<logger name="*" minlevel="Debug" writeTo="logtail" />
And that's all πŸŽ‰ You can now use NLog the way you're used to and your logs will be forwarded to Logtail.
Make sure you replace YOUR_SOURCE_TOKEN with your own source token from Logtail.com.

Additional configuration

The Logtail target will send you logs periodically in batches to optimize network traffic with several retries in case of unexpected HTTP errors. You can adjust this behavior by setting the maxBatchSize, flushPeriodMilliseconds, and retries params to your custom values in your config.
retries="3" />

Structured logging with NLog

All of the properties that you pass to the log will be stored in a structured form in the context section of the logged event. For example, this snippet
"The answer to the meaning of life, the universe and everything: {answer}",
will generate a log event similar to:
"dt": "2021-08-30T07:02:15.452487Z"
"level": "info",
"message": "The answer to the meaning of life, the universe and everything: 42",
"context": {
"properties": {
"answer": 42
"runtime": { ... }
You can then filter your logs according to the context.properties.answer_integer field in Live Tail or you can use this column in your custom SQL queries to find relevant logs or to create custom reports.