Search code examples
nlogsentry

Sentry.NLog not logging to Sentry


Trying to get Sentry wired up via NLog, and not having much luck.

Packages:

<package id="Sentry" version="3.0.5" targetFramework="net462" />
<package id="Sentry.NLog" version="3.0.5" targetFramework="net462" />

Both latest.

NLog.config:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      throwExceptions="true"
      internalLogLevel="Debug"
      internalLogFile="c:\temp\nlog-internal.txt"
      internalLogToConsole="true"
      throwConfigExceptions="true">

  <extensions>
    <add assembly="Sentry.NLog" />
  </extensions>

  <targets>
    <target xsi:type="Sentry"
            name="sentry"
            dsn="https://secret"
            environment="test"
            includeEventProperties="True"
            layout="${message}"
            breadcrumbLayout="${message}"
            minimumBreadcrumbLevel="Debug"
            ignoreEventsWithNoException="False"
            includeEventDataOnBreadcrumbs="False"
            includeEventPropertiesAsTags="True"
            minimumEventLevel="Error" />    
  </targets>

  <rules>
    <logger name="*" minlevel="Error" writeTo="sentry" />
  </rules>

</nlog>

Things I've checked:

  • DSN. Copied and pasted from the Sentry portal, so i know it's correct
  • No filters on 'environments' in Sentry.
  • Nlog log file shows no errors. In fact in shows Sentry being wired up.
  • Added other targets to NLog (e.g console, file, etc), they work fine.

Any ideas?

Thanks


Solution

  • Sentry is sending data over the network, and propbably has an artificial delay to optimize for batching and to reduce network-traffic.

    Did you remember to flush?, and wait for the data to arrive at destination.