Serilog Sqlite中的自定义列

发布于 2025-02-06 03:09:09 字数 234 浏览 4 评论 0 原文

我目前使用serilog.sinks.sqlite写入sqlite db文件。这可以正常工作,但是我想在此DB文件中创建自定义列。我已经设法用各种富集器(ProcessName,EnviroMentName等)丰富了属性列,但是我需要符合特定的列格式。

我找不到此软件包上的任何有价值的文档。如何创建这些自定义列?

替代解决方案: 如何配置(已记录的大量记录)MSSQL接收器以写入SQLite文件?

提前致谢!

Im currently writing to a SQLite db file using Serilog.Sinks.SqLite. This works fine however i would like to create custom columns in this db file. I have managed to Enrich the properties column with various enrichers (ProcessName, EnviromentName etc) but i need to conform to a specific column format.

I cant find any worthwhile documentation on this package. How would one go about creating these custom columns?

Alternative solution:
How can i configure the (much beter documented) MSSQL sink to write to an SQLite file?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长伴 2025-02-13 03:09:09

有点晚了,但我会回答。

您可以从 serilog.sinks.sqlite 。
在您的解决方案中,删除了 serilog.sinks.sqlite dll的引用后,您可以将参考添加到下载的项目中。

在新的源代码中,您可以访问 sqlitesink.cs 文件,并根据需要修改以下方法:

  • createTable :您可以定义列
  • createSqlinSertCommand :设置插入命令以下按下表定义
  • writetodatabasync :定义插入命令的参数值

It's a bit late but I'll give my answer.

You can download the source code of Serilog.Sinks.SqLite from github.
In your solution, after removing the reference of Serilog.Sinks.SQLite dll you have, you can add the reference to the downloaded project.

In the new source code you can access the SQLiteSink.cs file and modify the following method per your needs:

  • CreateTable: you can define your columns
  • CreateSqlInsertCommand: set the INSERT command following the table definition
  • WriteToDatabaseAsync: define the parameter values for your INSERT command
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文