1

Trying to send logs to remote http server using serilog-sinks-http and Serilog.Exceptions is required to get exception details.

In Serilog.Exceptions documents it required outputTemplate to be set to {Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception} {Properties:j} to work.

Couldn't find outputTemplate parameter in HTTP Sink, now logs look similar to:

03/06/2024 13:00:00 +03:30 [Error] Error occured
System.DivideByZeroException: Attempted to divide by zero.
   at logexample.Program.Main(String[] args) in D:\repos\logexample\Program.cs:line 29

Also innerException is needed to be placed in logs (innerException itself may contain another innerException which all are needed).

4
  • There are fundamentally two type of sinks - text-based (console, file) and structured (all others). OutputTemplate string is applied only to first type of them. HttpSink just sends LogEvent occured as application/json content. So, no need for you to set up template for serilog-sinks-http. Commented Mar 6, 2024 at 10:22
  • Then how should I get exception details to send via HTTP sink ? Commented Mar 6, 2024 at 10:23
  • Check out sample code. I did not check for the case with ExceptionDetails, but basic usage puts Exception text as part of RenderedMessage property. Commented Mar 6, 2024 at 10:30
  • I believe details should be part of the message too. Commented Mar 6, 2024 at 10:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.