How to configure Seq to include exception stack trace

667 views Asked by At

I have installed Seq in my local Sitecore instance.
The portal displays the logs & errors, but I'm unable to figure out the following:

  1. After an error is logged, it takes around 3 mins to show up in Seq. Can we configure it to display real-time.
  2. I do not see the exception & stack trace as shown in snap. What needs to be configured to view them.

enter image description here

In the portal, I would like to show the "Message" and in it's collapsible details, I would like to have the stack trace. Is it possible.

In my Sitecore instance (the notepad in snap), you can see how the error is logged. But in Seq portal it only says "STRATUM_ERROR".

I would like it to display "STARTUM_ERROR Input string was not in a correct format".
And the stack trace in its collapsible table.

So, I added nuget for Serilog.Exeptions and modified my class method like this:

protected override void SendBuffer(LoggingEvent[] events)
        {
            using (var log = new LoggerConfiguration()
                .MinimumLevel.ControlledBy(new LoggingLevelSwitch(GetLogEventLevel()))
                .Enrich.FromLogContext()
                .Enrich.WithExceptionDetails(new DestructuringOptionsBuilder()
                       .WithDefaultDestructurers()
                       .WithRootName("Message").WithRootName("Exception").WithRootName("Source")
                       )
                .Enrich.WithMachineName()
                .Enrich.WithEnvironmentUserName()
                .Enrich.WithProcessId()
                .Enrich.WithProcessName()
                .Enrich.WithProperty("ThreadId", SystemInfo.CurrentThreadId)
                .Enrich.WithMemoryUsage()
                .WriteTo.Seq(SeqHost, apiKey: ApiKey)
                .CreateLogger())
            {
                foreach (var thisEvent in events)
                {
                    LogEvent(log, thisEvent);
                }
            }

        }

private void LogEvent(Logger log, LoggingEvent loggingEvent)
        {
if (loggingEvent.Level == Level.ERROR)
                {
                    message.AppendLine(loggingEvent.RenderedMessage);
                    message.AppendLine(loggingEvent.GetExceptionStrRep());
                    log.Error(message.ToString());                        
                }
    }

But now it shows like this:

enter image description here

Seems like the .Enrich.WithExceptionDetails has no effect.

0

There are 0 answers