Skip to content

Instantly share code, notes, and snippets.

@light-traveller
Last active July 8, 2023 12:19
Show Gist options
  • Save light-traveller/dbdb5e1816d549f95d7f8540ac17b8c4 to your computer and use it in GitHub Desktop.
Save light-traveller/dbdb5e1816d549f95d7f8540ac17b8c4 to your computer and use it in GitHub Desktop.
Serilog config
/*
Nuget packages: Serilog, Serilog.AspNetCore, Serilog.Sinks.Console, Serilog.Sinks.File
*/
{
"Serilog": {
"Using": ["Serilog.Sinks.Console", "Serilog.Sinks.File"],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Literate, Serilog.Sinks.Console",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "./bin/log.txt",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": ["FromLogContext", "WithMachineName", "WithThreadId", "WithEnvironmentUserName"]
}
}
@light-traveller
Copy link
Author

light-traveller commented Jul 8, 2023

Added enrichers (not working by default).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment