Added additional providers and correlationId (by using a LogContext)

This commit is contained in:
2025-04-25 21:23:41 +02:00
parent d7944065a6
commit 60777caaa5
31 changed files with 1194 additions and 7 deletions

View File

@@ -378,4 +378,15 @@ private void LogHelper_OnException(object sender, ErrorMessage e)
Console.WriteLine("Error message from logger: " + e.Message)
}
}
```
```
Example of adding custom context to the log messages:
```csharp
var jsonLogger = new JsonFileLoggerProvider().CreateLogger("MyCategory") as JsonFileLogger;
jsonLogger?.SetContext("CorrelationId", "abc-123");
jsonLogger?.SetContext("UserId", "john.doe");
jsonLogger?.LogInformation("User logged in");
````
// Output:
// [2025-04-25 17:01:00Z] [Information] MyCategory: User logged in | CorrelationId=abc-123 UserId=john.doe