log4net appenders never flush their client, so events are lost at shutdown

Offen Anfängerfreundlich
#390 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 6 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
78/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
csharp
Bereich
backend

Rechercherichtung

Lies ExceptionlessAppender.cs und BufferingExceptionlessAppender.cs an den verlinkten Stellen und vergleiche dann die Behandlung beim Herunterfahren mit ExceptionlessTarget.cs. Verfolge, wie jeder Appender seinen Client erstellt und wie das Schließen des Puffers Ereignisse übermittelt; abgeschlossen ist die Aufgabe, wenn das Schließen oder Leeren die in der Warteschlange befindlichen Ereignisse innerhalb des Zeitlimits verarbeitet und nur einen Client freigibt, den der Appender erstellt hat.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug

In Exceptionless.Log4net 6.2.0, when ApiKey or ServerUrl is set on ExceptionlessAppender or BufferingExceptionlessAppender, the appender creates its own ExceptionlessClient with in-memory storage. Nothing ever processes that client's queue on close or flush, so events logged shortly before the process exits are never sent.

Where

For comparison, the NLog target flushes its client: https://github.com/exceptionless/Exceptionless.Net/blob/5792f00d175f94a35fe0559c8e9999234a8163be/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs#L96-L98

What happens

  • The private client is never started, so it does not register the process-exit handler that Startup() registers for other clients.
  • Neither appender overrides OnClose or Flush, so LogManager.Shutdown() / LogManager.Flush() do not send queued events.
  • The queue is only processed by the client's timer (first run after 2 seconds, then every 10 seconds). Events logged in the last few seconds before exit stay in memory and are lost. For BufferingExceptionlessAppender, the buffer is handed to the client on close, but the client's queue is still never sent.
  • The client is never disposed either.

Expected

Closing or flushing the appender (for example LogManager.Shutdown()) sends the queued events, and the appender disposes a client it created.

Steps to reproduce

  1. Configure ExceptionlessAppender in log4net with <apiKey value="..." />.
  2. In a console app, log an error and then call LogManager.Shutdown() and exit.
  3. The event never arrives in Exceptionless.

Suggested fix

In both appenders, override OnClose (calling the base first for the buffering appender so the buffer is submitted) and Flush(int millisecondsTimeout) to call _client.ProcessQueueAsync() and wait up to the timeout, and dispose the client in OnClose when the appender created it.

Vorherrschende Sprache
C#
Sterne
573
Forks
143
Ø Merge
5 T. 9 Std.
Gemergte PRs (30 T.)
1

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus exceptionless/Exceptionless.Net

Alle Issues in exceptionless/Exceptionless.Net

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.