AlanBarber / log4net.Appender.Splunk

A log4net appender for Splunk Http Event Collector (HEC) Sender
Apache License 2.0
7 stars 16 forks source link

Dn/batch logging+fix retries+ignore certificate #15

Closed DimitryNechaev closed 5 years ago

DimitryNechaev commented 5 years ago

I'm addressing several issues blocking me from logging to Splunk from MVC based cloud app.

  1. The messages were logged in synchronous way, one at a time. The app is logging around ~5000 on startup.

  2. The self-signed certificate of a trial version won't work with default implementation.

  3. The "retry" logic didn't work in MVC (not sure of console app) because of waiting for delay in async task called from sync task never completed. So if you currently put a breakpoint below await Task.Delay(retryDelay) in HttpEventCollectorResendMiddleware it will never be hit.

So my code changes are

  1. Remove Microsoft.CodeDom.Providers.DotNetCompilerPlatform as it will REQUIRE Rolsen. You don't need this for MVC project to run at all.
  2. Expose options for batch processing into configuration.
  3. Add option and logic for ignoring certificate errors.
  4. Refactor a bit with calling async PostEvents from sync Flush, so error delays in retries will work as expected.
  5. Filled SplunkHttpEventCollector.Flush. Expecting this to be called by log4net on app closing (not happening in dev, where I just shut the process. TODO this bit needs further investigation to make sure log4net flushes in IIS ASP.NET site on server shut down.

Tested the changes in MVC and Console app. Didn't test the web app.

AlanBarber commented 5 years ago

i'm going to pull this in but then do some rework based upon changes that have been made in my NLog.Targets.Splunk repo before releasing the 3.0.0 version.