Serilog Splunk is not logging messages

1.8k views Asked by At

I have a simple console app with the following code, to log into Splunk which is not working. I dont see any logs in the Splunk dashboard. I have masked the url and token.

var url = "https://http-inputs-*****.splunkcloud.com/services/collector";
var log = new LoggerConfiguration()
    .WriteTo.EventCollector(url, "49A89C45-****-47D2-8A4C-EF89DA*****", index:"app_crius_services")
    .CreateLogger();
    

log.Error(JsonConvert.SerializeObject(new ExceptionMessage
    {Index = "app_crius_services", Event = new Event()}));
log.Debug(JsonConvert.SerializeObject(new ExceptionMessage
    {Index = "app_crius_services", Event = new Event()}));
log.Information(JsonConvert.SerializeObject(new ExceptionMessage
    {Index = "app_crius_services", Event = new Event()}));

I am using the same URL and token to post similar kinds of messages using Postman, and those arrive successfully (I can see them in my Splunk dashboard).

Is there anything that I am doing wrong, or is my logger configuration is incorrect?

1

There are 1 answers

2
user1505521 On

So serilog actually batches the events and scans those batches in an interval to make an http post, the issue was the program being exited before the scan happened. The following link demonstrates how to force flush the sink.

https://github.com/serilog/serilog-sinks-splunk/issues/95