Well, what appears to be happening is that my program ends without calling flush().
So, my question is: is there a way to tell nlog to flush the queue when shutting down?
In my simple console test app, I can call flush at the end of main, and everything works hunky dory. however, in the real app(s), I register for AppDomain.CurrentDomain.DomainUnload or AppDomain.CurrentDomain.ProcessExit events in order to know when to call flush. The problem is that if there are a lot of entries left in the queue by the time the main thread is leaving the main function, these events are never raised, so I never call flush, and the remaining entries are discarded. If the queue is empty, then the events ARE raised. --not sure what's preventing this event.
A work around: If I wrap my target in an AutoFlush wrapper, no events are lost, but I essentially lose any advantage of batching my database writes. --it is most often writing 1 or 2 events at a time, regardless of the timeToSleepBetweenBatches.
From the last line of the internal nlog file, Closing target NLog.Targets.Wrappers.AsyncTargetWrapper (DBTarget). It apparently closes it without first flushing the queue.
Any help is appreciated.
NLogFile.txt