简体   繁体   English

Serilog .write(logevent)使用mssqlserver接收器

[英]Serilog .write(logevent) using mssqlserver sink

Am reading log data (created using serilog from other apps) from a message queue (using rabbitmq) & want to write these to sql server table using serilog mssqlserver sink in a windows service. 我正在从消息队列(使用Rabbitmq)读取日志数据(使用其他应用程序中的serilog创建),并希望使用Windows服务中的serilog mssqlserver sink将这些数据写入sql服务器表。

Am attempting to go about this using the .Write(LogEvent) method in the serilog api. 我正在尝试使用serilog api中的.Write(LogEvent)方法进行此操作。

Am struggling on the following parameters to populate from the data in the queue: 我正在努力从队列中的数据填充以下参数:

  • LogEventLevel level LogEventLevel级别
  • IEnumerable <LogEventProperty> properties IEnumerable <LogEventProperty>属性

Does anyone have a nice example of how to use this method with above params? 有没有人有一个很好的例子说明如何在上面的参数中使用此方法?

When you write the events to the message queue, use CompactJsonFormatter to create the JSON, from https://github.com/serilog/serilog-formatting-compact . 将事件写入消息队列时,请使用CompactJsonFormatterhttps://github.com/serilog/serilog-formatting-compact创建JSON。

Then, to read them back out as Serilog events, use LogEventReader from https://github.com/serilog/serilog-formatting-compact-reader . 然后,要将它们作为Serilog事件读回,请使用https://github.com/serilog/serilog-formatting-compact-reader中的 LogEventReader

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM