jjchiw / gelf4net

GELF log4net Appender - graylog2
MIT License
63 stars 59 forks source link

AsyncGelfHttpAppender error in OnClose() method. #71

Open FedericoBusso opened 4 years ago

FedericoBusso commented 4 years ago

When setting an invalid URL on the appender, the application crashes when trying to log with the following error:

https://i.imgur.com/b50Zegs.png

with the following appender config:

https://i.imgur.com/ApQL4Xu.png

Looking through the code, the OnClose of the appender has the _sender property set to null since the

base.ActivateOptions();

fails.

could probably fix this by just putting the _sender initialization before callind the base.ActivateOptions in the AsyncGelfHttpAppender's own ActivateOptions.

jjchiw commented 4 years ago

Hi!

I think the exception is correct based on that the input (URL) is invalid....

Why the library should continue executing if it's not going to do what it's expected....

FedericoBusso commented 4 years ago

Hi!

The exception is correct. I might've not been clear enough, my question would be:

On initial app load, the appender fails to be created which is what is expected. Then, it'd be expected that any logging calls just don't do anything but instead the OnClose() method of the appender is being called which causes said crash.

Why would the OnClose() method be called if it wasn't added to the root logger?

I'm sorry if I'm mistaken on something, just trying to figure this one out.

Thanks a bunch