# Templates für Logging Konfigurationen
Auf dieser Seite sind verschiedene Vorlagen für die Logging-Konfiguration aufgeführt. Viele dieser Vorlagen können einfach kopiert werden, um eine bestehende Logging-Konfiguration zu ersetzen.
# Überlaufende Logdatei
Das Protokoll wird in eine Datei geschrieben, die für jeden Tag oder nach 75 Megabyte überläuft.
{
"Serilog": {
"Using": [
"Serilog.Sinks.File"
],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "File",
"Args": {
// 75 MiB file size limit
"fileSizeLimitBytes": 78643200,
"retainedFileCountLimit": 20,
"path": "Logs/ELOSync.log",
"rollingInterval": "Day"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithThreadId"
],
"Properties": {
"Application": "ELO Sync"
}
}
}
# Einfache Konsolenausgabe
Log wird nur in die Konsolenausgabe (stdout) des ELO Sync-Prozesses geschrieben.
{
"Serilog": {
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Console"
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithThreadId"
],
"Properties": {
"Application": "ELO Sync"
}
}
}
# Asynchrone Konsolenausgabe
Log wird nur auf die Konsolenausgabe (stdout) geschrieben, aber asynchron, sodass die Protokollierung selbst den Prozess nicht wesentlich verlangsamt. Der größte Nachteil ist, dass Log-Meldungen in der falschen Reihenfolge geschrieben werden können.
{
"Serilog": {
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Async",
"Args": {
"configure": {
"Name": "Console"
}
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithThreadId"
],
"Properties": {
"Application": "ELO Sync"
}
}
}
# Konsolenausgabe im JSON-Format
Log wird nur auf die Konsolenausgabe (stdout) in einem JSON-Format geschrieben.
{
"Serilog": {
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Console",
"Args": {
"formatter": "Serilog.Formatting.Json.JsonFormatter"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithThreadId"
],
"Properties": {
"Application": "ELO Sync"
}
}
}
# Konsolenausgabe im kompakten JSON-Format (CLEF)
Log wird nur in die Konsolenausgabe (stdout) im JSON-basierten CLEF-Format geschrieben.
{
"Serilog": {
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Console",
"Args": {
"formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithThreadId"
],
"Properties": {
"Application": "ELO Sync"
}
}
}
# Konsolenausgabe im CLEF-Format und Überlaufende Logdatei
Ein Beispiel für die Kombination mehrerer Log-Ausgaben.
{
"Serilog": {
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Console",
"Args": {
"formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact"
}
},
{
"Name": "File",
"Args": {
// 75 MiB file size limit
"fileSizeLimitBytes": 78643200,
"retainedFileCountLimit": 20,
"path": "Logs/ELOSync.log",
"rollingInterval": "Day"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithThreadId"
],
"Properties": {
"Application": "ELO Sync"
}
}
}