datalust/serilog-sinks-seq

Want more information when HttpRequestException thrown

Closed this issue · 2 comments

I have encountered a situation in which the Seq sink logs (to the SelfLog) that an HttpRequestException has occurred. See below for the entire log entry. As part of my troubleshooting process, I would like to see the URL that Seq used as the host in this failed HTTP request.

Using the current version, is it possible for me to determine what this host URL is?

In any case, could the error message be improved to include the host URL?

I believe that this line of code wrote this message.

Exception while emitting periodic batch from Serilog.Sinks.Seq.SeqSink: System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: ConnectFailure (Connection refused) ---> System.Net.Sockets.SocketException: Connection refused
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x000b6] in <2a35d68bc192428fa381a1ddd21b6dc6>:0
  at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x0016d] in <2a35d68bc192428fa381a1ddd21b6dc6>:0
   --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetRequestStream (System.IAsyncResult asyncResult) [0x0003a] in <2a35d68bc192428fa381a1ddd21b6dc6>:0
  at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x002e7] in <0594b282664f42bfb93000f40b0f896b>:0
   --- End of inner exception stack trace ---
  at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x004ab] in <0594b282664f42bfb93000f40b0f896b>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Net.Http.HttpClient+<SendAsyncWorker>d__47.MoveNext () [0x000ca] in <0594b282664f42bfb93000f40b0f896b>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at Serilog.Sinks.Seq.SeqSink+<EmitBatchAsync>d__14.MoveNext () [0x0010d] in <d9b4c3c8b77e49b4b2eec3e8fcf8ea11>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <a86d3bc2261c42eb9fc880c3d795a3a1>:0
  at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink+<OnTick>d__16.MoveNext () [0x0012e] in <205ec8d149b64ceeb81ee03c63bd3f1b>:0

Thanks for the suggestion! There's no mechanism to include that information in the current version, but I think it would be useful to add 👍

Thanks again for raising this, Tyson; we don't think we'll attempt to improve this at this stage, in the expectation that in these scenarios, dumping out logger configuration somehow would be more useful (and outside the scope of this project). Thanks!