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

No request is made, no error thrown #95

Closed mtman closed 6 years ago

mtman commented 6 years ago

Steps

dotnet new console -n serilog-splunk-issue
cd serilog-splunk-issue
dotnet add package serilog
dotnet add package serilog.sinks.splunk

Program.cs:

using System;
using Serilog;

namespace serilog_splunk_issue
{
    class Program
    {
        static void Main(string[] args)
        {
            Serilog.Debugging.SelfLog.Enable(Console.Error);

            var log = new LoggerConfiguration()
                .WriteTo.EventCollector("http://192.168.0.11:8088/services/collector", "ea6595dc-72f2-40fd-94c5-c93300dc0158")
                .CreateLogger();

            log.Information("test");
        }
    }
}
dotnet run

Result

No console output.

No records were added.

Fiddler doesn't show any request to 192.168.0.11

merbla commented 6 years ago

Hi @mtman,

Can you try calling log.CloseAndFlush(), under the hood this sink uses the period batching sink so events are not immediately flushed. Middleware and frameworks such as ASP.Net do this sometimes as the request pipeline level. You will find similar behaviour in other HTTP sinks.

Hope this helps!

mtman commented 6 years ago

That was indeed the problem. Thanks a lot.

vsix27 commented 2 years ago

it looks like there is no method CloseAndFlush() anymore... i can write message to splunk from curl but not from java or .net core... no errors, ne messages in curl i have splunkhost https://localhost:8088/services/collector, in .net/java using https://localhost:8088 (tried with services/collector too)

j2jensen commented 1 year ago

@vsix27 Log.CloseAndFlush() just calls the Dispose() method on the default logger instance. Have you tried calling Dispose()?