Open DontWorry33 opened 5 years ago
One difference between your sample and the one you mentioned is that your are using bufferSize=1
. The sample uses 100 which uses the bulk API. I'm not sure it has anything to do because this Appender derives from BufferingAppenderSkeleton
, which is asynchronous. So in any case you should make sure events are flushed before exiting. I would expect you to Flush all queued events at the end of the app.
This was raised on stackoverflow:
To wait up to 2 seconds to flush queued events:
LogManager.Flush(2000);
Hello,
When I was trying to create an example application (similar to https://github.com/jptoto/log4net.ES.Example but for .NET Core instead), I realized that logging into elastic does not work unless there is a
Console.ReadKey()
or anything that lets the application halt its execution at the end of the Program. This is not the same case when running the example application linked above as that one will work without putting aConsole.ReadKey()
. My assumption is that it has to do something with async tasks not completing because when I tried to debug the issue, it seemed like the program doesn't continue on to the Post method (my breakpoint never gets hit) after this line in Repository.cs :logEvents.Do(logEvent => httpClient.Post(uri, logEvent));
I also don't get any errors reported without the Console.ReadKey().
Here is my configuration:
Program.cs
log4net.config
Uncommenting the Console.ReadKey() and waiting a second before terminating the application will successfully log the messages to Elastic, however, if I throw an exception in Repository.cs (line 47), I get the following errors: