question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sentry.NLog not logging to Sentry

See original GitHub issue

Please mark the type framework used:

  • ASP.NET MVC
  • ASP.NET Web API (OWIN)
  • ASP.NET Core
  • WPF
  • WinForms
  • Xamarin
  • Other: .NET 4.6.2 console app

Please mark the type of the runtime used:

  • .NET Framework
  • Mono
  • .NET Core
  • Version: 4.6.2

Please mark the NuGet packages used:

  • Sentry
  • Sentry.Serilog
  • Sentry.NLog
  • Sentry.Log4Net
  • Sentry.Extensions.Logging
  • Sentry.AspNetCore
  • Version: 3.0.5

Hi there! 👋

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

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
RPM1984commented, Feb 15, 2021

@bruno-garcia my bad. I think the problem was i wasn’t waiting long enough for it to ‘flush’. I was logging, then killing my app.

I let it run for a while, and it eventually came through. I guess i expected all NLog events to ‘flush’ at the same time. In this case, it was flushing to output 1 immediately, but Sentinel a few seconds later.

All good, will close issue. Sorry and thanks 😊

0reactions
bruno-garciacommented, Feb 15, 2021

You can call SentrySdk.Close() at the end of the app execution to flush things out.

Ideally NLog Flush would pipe to sentry flush if that not the case yet

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sentry.NLog not logging to 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),...
Read more >
Sentry.NLog Logs to NLog but Not to Sentry - SDKs
I am using the latest Sentry/NLog packages (as shown below) but for some reason, my errors are begin logged to NLog but not...
Read more >
Troubleshooting for NLog
The following message may appear in your build output: The Sentry CLI is not fully configured with authentication, organization, and project. The message ......
Read more >
Sentry.Samples.NLog does not work ...
LogInfo, Errors and etc should all be written to the console as it's one of the target. ... then nlog will work correctly...
Read more >
Sentry.NLog 3.35.0
Official NLog integration for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found