Skip to content

params arguments should be regarded as optional #441

@sreejith-kulamgarath

Description

@sreejith-kulamgarath

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"
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions