Skip to content

Instantly share code, notes, and snippets.

@gubser
Created February 24, 2023 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gubser/fa1004a5c3b677b209d92ddb3f1280c0 to your computer and use it in GitHub Desktop.
Save gubser/fa1004a5c3b677b209d92ddb3f1280c0 to your computer and use it in GitHub Desktop.
Serilog Expression that truncates exception stack trace to 10'000 chars
var formatter = new ExpressionTemplate("{ {@t, @m, @r, @l: if @l = 'Information' then undefined() else @l, @x: if Length(@x) > 10000 then Concat(Substring(@x, 0, 9997), '...') else @x, ..@p} }\n")
LoggerConfiguration().WriteTo.Console(formatter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment