gpt4 book ai didi

configuration - 有没有办法用配置中的属性丰富日志?

转载 作者:行者123 更新时间:2023-12-02 20:24:06 24 4
gpt4 key购买 nike

我知道我可以通过这种方式添加增强剂:

{
"Serilog": {
"Using": [
"Serilog",
"Serilog.Enrichers.Environment",
"Serilog.Enrichers.Process",
...
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithProcessId"
]
...

我可以对属性 (ApplicationName) 做同样的事情吗?

最佳答案

实现此目的的一种方法是使用属性。但是丰富属性的配置有一个警告,它是顶级配置而不是丰富配置:

{
"Serilog": {
"Using": [
"Serilog",
"Serilog.Enrichers.Environment",
"Serilog.Enrichers.Process",
...
],
"Properties": {
"ApplicationName": "my application"
},
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithProcessId"
]
...

这将导致配置读取器调用如下内容:

loggerConfiguration.Enrich.WithProperty("ApplicationName", "my application");

关于configuration - 有没有办法用配置中的属性丰富日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50486481/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com