The Serilog.Exceptions package for Serilog.
Questions tagged [serilog-exceptions]
31 questions
8
votes
1 answer
Serilog different levels for different sinks
I have the following piece of c# code for writing logs with multiple sinks (console and file), how do i restrict the console to log only (info, warn and error) and file to log everything.
var outputTemplate = "[{Level:u3}]…

nen
- 621
- 2
- 10
- 26
5
votes
2 answers
How to configure Serilog with different log levels for each namespace in my project? I want to do it via application.json config file
We are writing a new logging functionality and injecting into our existing services.
Following is the way we do it:
1) Setup Serilog using UseSerilog() call in Program.cs
2) Setup Serilog config in appsettings.json to setup sinks for writing to Log…

CodeTruthSeeker
- 83
- 1
- 8
5
votes
1 answer
How to configure Serilog.Exceptions.SqlServer in appsettings.json
I'm using appsettings.json to configure Serilog. I added Serilog.Exceptions, which works like a charm.
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Settings.Configuration", "Serilog.Exceptions" ],
"MinimumLevel": {
…

Johan Vergeer
- 5,208
- 10
- 48
- 105
4
votes
2 answers
Is it possible to disabled the reflection based destructurer in Serilog.Exceptions?
The package Serilog.Exceptions is nice for logging exceptions. It has a large list of supported exception types.
e.g. the current setup:
Log.Logger = new LoggerConfiguration()
.Enrich.WithExceptionDetails()
.CreateLogger();
Currently it…

Julian
- 33,915
- 22
- 119
- 174
3
votes
2 answers
Log without Exception stack trace in Serilog
I am using Serilog and Serilog.Exceptions for structured logging purposes in my MVC5 application.
I want to remove the stack trace from the value of the "Exception" field in the log. I understand that I am using the new JsonFormatter() in the…

Junaid
- 941
- 2
- 14
- 38
3
votes
1 answer
asp.net core - Set Serilog.Exceptions from appsettings.json
I need to use Serilog.Exceptions package to catch exceptions.
Serilog is read from appsettings.json
{
"Serilog": {
"Using": [
"Serilog.Sinks.RollingFile",
"Serilog.Sinks.Seq"
],
"WriteTo": [
…

Mini Dev 1
- 169
- 1
- 2
- 8
2
votes
1 answer
Can't use Serilog Middleware on .NET 6 Project
I'm building a .NET 6 project and trying to put Serilog to work properly on it.
Everything seems to work fine, but when I try to add SerilogMiddlware for requests I get this exception:
Unable to resolve service for type…

sathoril
- 96
- 2
- 8
2
votes
2 answers
Hello World with SeriLog and PowerShell
I'm trying to understand how to use SeriLog in PS.
This is an example of code that works:
$SeriLog = Add-Type -Path "C:\Program Files\PackageManagement\Serilog.2.10.0\lib\net46\Serilog.dll" -PassThru
$SeriLog_Sink_Console = Add-Type -Path…

Eric C. Singer
- 123
- 4
2
votes
2 answers
Serilog - Separate files for Information, exception using appsetting.json
I am writing all logs into one file(s) using rolling. But I want to separate them by Information, Warning and Exceptions rolling files.
my current configuration is like this
"Serilog": {
"WriteTo": [
{
"Name": "RollingFile",
…

James123
- 11,184
- 66
- 189
- 343
2
votes
1 answer
Serilog - How to stop request life cycle logs and enable only custom Information logs
I am using ASP.NET Core 3.1, I have included the nuget for serilog "Serilog.AspNetCore" version 3.2.0.
Configured to log to a file as below:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
…

sm101
- 562
- 3
- 10
- 28
2
votes
1 answer
is there a way to overwrite Serilog global logger's log level
the scenario I want is to set the global log level to Error. this is my config code which is called in startup class:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Error()
…

dora
- 23
- 4
2
votes
1 answer
JSON Configuration for Serilog.Exception destructurers
I am adding Serilog to the project and I specifically want to add Serilog.Exceptions as well. Following the guideline I've added just the Exceptions enricher successfully, but I also need the destructures mentioned in the linked page.
The following…

Yuriy Ivaskevych
- 956
- 8
- 18
1
vote
0 answers
How to configure Seq to include exception stack trace
I have installed Seq in my local Sitecore instance.
The portal displays the logs & errors, but I'm unable to figure out the following:
After an error is logged, it takes around 3 mins to show up in Seq. Can we configure it to display real-time.
I…

sukesh
- 2,379
- 12
- 56
- 111
1
vote
1 answer
Serilog middleware excludes userid from error messages, anyone know why?
I wrote a small serilog middleware that I'd like to capture the user id from the httpcontext and include it in log files. It works for normal logs, but not for unhandled exceptions. This is for .net core. Anyone know why?
Thank you!
public class…

NullReference
- 4,404
- 12
- 53
- 90
1
vote
0 answers
How to log Serilog debug messages conditionally in .NET 6?
I am working on a .net 6 application. I have used Serilog for logging. I have received a request to log the debug logs based on the database settings.
Below is my setting table:
Create table ApplicationSettings
(
Id UNIQUEIDENTIFIER PRIMARY KEY…

Shaksham Singh
- 491
- 1
- 5
- 19