serilog-contrib / serilog-sinks-splunk

A Serilog sink that writes to Splunk
https://splunk.com
Apache License 2.0
46 stars 47 forks source link

Issue with overload #162

Closed vzalamea closed 1 year ago

vzalamea commented 1 year ago

Logging using the "Information" level. The overload that accepts a string template and a params object[] works fine but the overload that accepts a string template and string[] array doesn't behave as expected. Shouldn't there be 2 properties "name" and "source"?.

ASP.NET Minimal API:

using Serilog;

Log.Logger = new LoggerConfiguration()
    .Enrich.FromLogContext()
    .WriteTo.EventCollector(
        splunkHost: "https://mysplunkhost:8080",
        eventCollectorToken: "b475fbb4-df6e-4620-9272-b2901a9b5dc4",
        source: "My Logging Service",
        restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Verbose,
        messageHandler: new HttpClientHandler
        {
            ServerCertificateCustomValidationCallback = (requestMessage, cert, chain, policyErrors) => true
        }
    )
    .CreateLogger();

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () =>
{
    Log.Information("Welcome, {name}, and hello from {source} using string[]!", new string[] { "Vince", "MyLoggingService" });
    Log.Information("Welcome, {name}, and hello from {source} using params object[]!", "Vince", "MyLoggingService");
    return "Hello World!";
});

app.Run();

Result: image

The 2nd parameter is described as "Object positionally formatted into the message template" image

vzalamea commented 1 year ago

If I use object[] instead of string[], it works Log.Information("Welcome, {name}, and hello from {source} using object[]!", new object[] { "Vince", "MyLoggingService" });