serilog-sinks-browserhttp icon indicating copy to clipboard operation
serilog-sinks-browserhttp copied to clipboard

Exceptions showing up as type TextException

Open JasonLooney opened this issue 1 year ago • 1 comments

We're using these libraries to send log messages from a Blazor WebAssembly app up to an ASP.NET server in Azure, which in turn logs to ApplicationInsights. However, all exceptions coming from the client are showing up as the type TextException in the logs and are missing the exception details.

How can we fix this?

On the client, our logger is configured like so:

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.ControlledBy(levelSwitch)
    .Enrich.WithProperty("InstanceId", Guid.NewGuid().ToString("n"))
    .WriteTo.BrowserHttp(controlLevelSwitch: levelSwitch, endpointUrl: $"{builder.HostEnvironment.BaseAddress}ingest")
    .CreateLogger();

And on the server:

builder.Host.UseSerilog((context, services, configuration) => configuration
    .ReadFrom.Configuration(context.Configuration)
    .ReadFrom.Services(services)
    .Enrich.FromLogContext()
    .WriteTo.ApplicationInsights(new TelemetryConfiguration { ConnectionString = appInsightsConnection }, TelemetryConverter.Traces));

// ...

webApp.UseSerilogIngestion();
webApp.UseSerilogRequestLogging();

JasonLooney avatar Jan 18 '24 16:01 JasonLooney