question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception Stack Trace detail stripped by sinks

See original GitHub issue

I am trying to use Serilog (with Seq) to log unhandled exceptions in my application. I noticed that while the console log would contain a full stack trace including source filenames and line numbers, the exception written to seq would not. After some investigation, I believe this problem is related to the sink code, or it’s an issue with the Exception class in general.

Seq uses PeriodicBatchingSink, and after stepping through the code in debug mode, I discovered that the logEvent.Exception property contains the full stack trace when it enters PeriodicBatchingSink.EmitBatch. As soon as it calls into the overridden method specific to the sink (SeqSink.EmitBatchAsync in this case), logEvent.Exception no longer contains the line number information (even if you view the variable from the previous caller in the call stack!).

I’m looking for a way to get this information passed through to Seq, preferably in the “proper” way - I’m using an enricher to serialise the stack trace into a second property at the moment as a workaround, but this is not ideal as my log message now contains two stack traces - one complete and one without line numbers.

Very simple sample program:

static void Main(string[] args)
{
    Log.Logger = new LoggerConfiguration()
        .WriteTo.ColoredConsole()
        .WriteTo.Seq("http://localhost:5341")
        .CreateLogger();

    try
    {
        throw new NotImplementedException();
    }
    catch (Exception ex)
    {
        Log.Error(ex, "error caught");
    }
}

This will cause a full stack trace to be printed to the console, but the version logged to Seq will only contain the function names - no file names or line numbers.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
JanKinablecommented, Jan 9, 2018

I’m still having the issue where the linenumbers are missing in the stack info. My setup: Serilog (2.5.0) in conjunction with AutofacSerilogIntegration (2.0.0) and Seq (Serilog.Sinks.Seq 3.4.0). The linenumbers are both missing in the logfiles as in Seq. Reading the above comments I can’t see this issue was fixed.

0reactions
nblumhardtcommented, Dec 15, 2016

Okay, thanks for the update Claire. I’ll close this one (again) but do please raise another if you find anything still amiss. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I remove exception stack traces from Serilog's ...
Message for just the console sink. So far I haven't found a way to do this. I did find this answer, which suggests...
Read more >
Should I be concerned if my website throws stack ...
On production (contrary to development) environments, stack traces and error messages should be logged to file instead of dumped on screen.
Read more >
Logger - loguru documentation - Read the Docs
Add a handler sending log messages to a sink adequately configured. ... diagnose ( bool , optional) – Whether the exception trace should...
Read more >
Use Crash Reporting for ASP.NET
This can be easily achieved by using our Serilog Sinks Raygun provider. ... NET exception needs to be thrown in order for its...
Read more >
Print or retrieve a stack traceback
Print exception information and stack trace entries from traceback object tb to file ... The line is a string with leading and trailing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found