只有自定义事件才会使用 Serilog 记录两次
我有一个实现 Serilog 的自定义记录器。跟踪记录一次,但事件记录两次。
下面是 host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
Appsettings:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"APPINSIGHTS_INSTRUMENTATIONKEY": "abcdef-ghi-49f9-bd20-xxxxxxxxxxx"
}
}
EventLogger 创建如下:
EventLogger = new LoggerConfiguration()
.ReadFrom.AppSettings()
.Enrich.FromLogContext()
.WriteTo
.ApplicationInsights(this.TelemetryConfiguration.InstrumentationKey, TelemetryConverter.Events).CreateLogger();
问题仅在于自定义事件。对于为什么会发生这种情况有什么想法吗?
I have a custom logger which implements serilog. Trace are getting logged once but the events are getting logged twice.
Below is the host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
Appsettings:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"APPINSIGHTS_INSTRUMENTATIONKEY": "abcdef-ghi-49f9-bd20-xxxxxxxxxxx"
}
}
EventLogger is created as below:
EventLogger = new LoggerConfiguration()
.ReadFrom.AppSettings()
.Enrich.FromLogContext()
.WriteTo
.ApplicationInsights(this.TelemetryConfiguration.InstrumentationKey, TelemetryConverter.Events).CreateLogger();
The problem is just with custom events.Any thoughts on why this can happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论