Added additional providers and correlationId (by using a LogContext)
This commit is contained in:
13
README.md
13
README.md
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user