I’ve posted this question on StackOverflow.com (asp.net - Sentry/NLog Integration Not Logging to Sentry - Stack Overflow) but I thought I would post here also in case this is a better place.
I am using the latest Sentry/NLog packages (as shown below) but for some reason, my errors are begin logged to NLog but not to Sentry.
I can see that Sentry is being initialized, but it never logs anything! Meanwhile, the errors are being logged to NLog without issue.
These are my relevant packages:
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="NLog" version="4.7.0" targetFramework="net472" />
<package id="Sentry" version="2.1.1" targetFramework="net472" />
<package id="Sentry.NLog" version="2.1.1" targetFramework="net472" />
<package id="Sentry.PlatformAbstractions" version="1.1.0" targetFramework="net472" />
<package id="Sentry.Protocol" version="2.1.1" targetFramework="net472" />
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net472" />
This is my NLog config file (I’ve removed my DSN for security reasons):
<?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"
throwConfigExceptions="true">
<extensions>
<add assembly="Sentry.NLog" />
</extensions>
<targets async="true">
<target name="SentryLogger" xsi:type="Sentry"
dsn="{removed for security reasons...}"
environment="${appsetting:item=Environment:default=Staging}"
InitializeSdk="true"
layout="${message}"
breadcrumbLayout="${message}"
minimumBreadcrumbLevel="Debug"
minimumEventLevel="Error">
<options
attachStacktrace="true"
sendDefaultPii="true"
shutdownTimeoutSeconds="5"
includeEventDataOnBreadcrumbs="true" />
</target>
<target name="default" xsi:type="File"
fileName="${basedir}/logs/${shortdate}.log"
archiveFileName="${basedir}/logs/archive-log/app-log.{#}.txt"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="30" />
</targets>
<rules>
<logger name="*" writeTo="default" />
<logger name="*" minlevel="Error" writeTo="SentryLogger" />
</rules>
</nlog>
Is there any reason why NLog would be working but not Sentry? I have other projects in the same solution which correctly log to both Sentry and NLog, just not this one!