.net-core - Serilog Splunk 不记录消息

标签 .net-core splunk serilog .net-core-logging

我有一个简单的控制台应用程序,其中包含以下代码,用于登录 Splunk,但该应用程序无法正常工作。我在 Splunk 仪表板中没有看到任何日志。我已经屏蔽了 url 和 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()}));

我使用相同的 URL 和 token 通过 Postman 发布类似类型的消息,并且这些消息成功到达(我可以在 Splunk 仪表板中看到它们)。

我做错了什么,还是我的记录器配置不正确?

最佳答案

因此,serilog 实际上对事件进行批处理,并在一定时间间隔内扫描这些批处理以进行 http post,问题是在扫描发生之前程序已退出。以下链接演示了如何强制冲洗水槽。

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

关于.net-core - Serilog Splunk 不记录消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67606081/

相关文章:

c# - 添加自定义 ExceptionFilter 后,Serilog 会立即停止记录异常

c# - 在 ASP.NET Core 2.2 中使用 InProcess 托管模型时,Serilog 不会将日志写入文件

c# - Rabbitmq,在发布者之前重启消费者

asp.net-core - 在 SignalR 的集线器外访问 Context.ConnectionID

python - 使用 python 的 Splunk REST Api : 201 with curl, 404?

regex - Splunk 的正则表达式

c# - Serilog topshelf 集成不起作用

macos - 点网 : command not found in Mac

entity-framework - .NET Core/EF Core (SQL) 使用(托管)后台服务时的最大池问题

regex - 这个正则表达式中的 (?i) 和 ?@ 是什么意思