Skip to content

Library does not log extra exception detail for Console Logger #86

Answered by krajek
eloisetaylor5693 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @eloisetaylor5693 , thanks for reaching out to us.

Serilog.Sinks.Console sink's default output template does not display enriched properties at all. Not for Serilog.Exceptions and not for any other sink (like standard Enrich.FromLogContext() or Enrich.WithProperty).

You need to specify custom template including Properties like that:

.WriteTo.Console(outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception} {Properties:j}")

Then your output will look like that:

2018-12-17 07:30:13.045 +01:00 [ERR] An error occurred
System.Exception: An exception message.
   at SerilogExceptionsLibUsingConsoleLogger.Program.ThrowAnException() in C:\Users\kraj…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by eloisetaylor5693
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #86 on December 15, 2020 15:24.