-
Notifications
You must be signed in to change notification settings - Fork 130
Open
Labels
Description
The following code was working with the previous version of TestCorrelator (3.2.0), but it is failing with v4.
Here is the code.
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(path: "appsettings.Test.json", optional: false, reloadOnChange: true)
.Build();
const string message = "An event.";
using var context = TestCorrelator.CreateContext();
Log = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
// Act
Log.Information(message);
// Assert
var logEvent = TestCorrelator.GetLogEventsFromCurrentContext().Single();
Assert.Equal(message, logEvent.MessageTemplate.Text);
If I replace ReadFrom.Configuration with this line, the code above works.
Log = new LoggerConfiguration().WriteTo.TestCorrelator().CreateLogger();
Here is my appsettings.Test.json
{
"Serilog": {
"Using": [
"Serilog.Sinks.TestCorrelator"
],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "TestCorrelator",
}
],
"Enrich": [
"FromLogContext"
],
"Properties": {
"Application": "Logging.Tests"
}
}
}