Using NLog

To use NLog with ASP.NET Core logging you must install the following Nuget package.

Install-Package NLog.Targets.InvisionLog

If you have an ASP.NET Core web application, then you also need to install the following package:

Install-Package NLog.Web.AspNetCore

Please see the NLog offcial Github page for more info on how to get started with NLog.

Minimal configuration

Add the following target to your nlog.config.

<target name="invisionlog" xsi:type="AsyncWrapper">
  <target xsi:type="InvisionLog" StaticKey="[static key]" ApplicationKey="[optional application key]" queueLimit="10000" batchSize="1000" />

And add the following rule to your nlog.config.

  <logger name="*" minlevel="Trace" writeTo="invisionlog" />

You can find your StaticKey in your InvisionLog Dashboard under Settings / API Keys. Optionally, you can also create an ApplicationKey there.

You are now ready to start logging to InvisionLog:

public class HomeController : Controller
    readonly ILogger<HomeController> _log;

    public HomeController(ILogger<HomeController> log)
        _log = log;

    public IActionResult Index()
        _log.LogInformation("Test information log!");

NLog target configuration

Key Description
ApplicationKey This setting is optional, until you start using it!
By default InvisionLog accepts all logs from all applications that uses the StaticKey.

You can create ApplicationKeys to differentiate between applications.
Once you create an ApplicationKey then all applications must be configured with an ApplicationKey. Preferably each app should use its own key.
StaticKey This key is required. You ccan find your StaticKey by logging into your Dashboard, then navigate to Api Keys.
queueLimit Limit on the number of requests in the lazy writer thread request queue. Default = 10000
batchSize Number of log events that should be processed in a batch by the lazy writer thread. Integer Default: 100 (NLog 4.4.2 and newer has Default: 200)