[英]Azure log analytics with Serilog stopped logging (MVC Core)
I have a pretty simple MVC Core 2.2 application that is utilizing Serilog and serilog-sinks-azure-analytics ( https://github.com/saleem-mirza/serilog-sinks-azure-analytics ) to pipe application logs to an Azure log analytics workspace.我有一个非常简单的 MVC Core 2.2 应用程序,它利用 Serilog 和 serilog-sinks-azure-analytics( https://github.com/saleem-mirza/serilog-sinks-azure-analytics )将应用程序日志通过管道传输到 Azure 日志分析工作区。 The implementation looks like this in Program.cs Program.cs 中的实现如下所示
public static void Main(string[] args)
{
var workspaceId = Configuration["AzureLogging:workspaceId"];
var authenticationId = Configuration["AzureLogging:authenticationId"];
var logName = Configuration["AzureLogging:logName"];
//Configure Serilog to add Azure Logging
Log.Logger = new LoggerConfiguration()
.WriteTo.AzureAnalytics(
workspaceId: workspaceId,
authenticationId: authenticationId,
logName: logName
)
.MinimumLevel.Information()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("System", LogEventLevel.Warning)
.CreateLogger();
CreateWebHostBuilder(args).Build().Run();
}
It collected logs for all of day then apparently stopped as when i query the last few hours via the log analytics workspace it returns nothing.它收集了一整天的日志,然后显然停止了,因为当我通过日志分析工作区查询过去几个小时时它什么都不返回。 If I run a query for the last 7 days I get a count of 350 records which is interesting.如果我在过去 7 天内运行查询,我会得到 350 条记录,这很有趣。
The documentation for the sink project states that the logBufferSize is 25,000 entries by default so it doesn't seem like I am hitting that. sink 项目的文档指出,默认情况下 logBufferSize 为 25,000 个条目,因此我似乎没有达到这一点。
I would appreciate any suggestions on how to diagnose where my logs are or why it might be failing.我将不胜感激有关如何诊断我的日志在哪里或它可能失败的原因的任何建议。
Thanks in advance.提前致谢。
There is a limit of about 500 custom fields per log analytics workspace .每个日志分析工作区有大约 500 个自定义字段的限制。
Go to Azure portal > Log Analytics workspace
> advanced settings
> Data
-> Custom fields for the current field count
and check the count.转到 Azure 门户 > Log Analytics workspace
> advanced settings
> Data
-> Custom fields for the current field count
并检查计数。
You could use Serilog.Sinks.AzureAnalytics
.您可以使用Serilog.Sinks.AzureAnalytics
。 This sink accepts an option parameter flattenObject
dictating if object properties should be flatten out when exporting to Azure.此接收器接受一个选项参数flattenObject
该参数指示在导出到 Azure 时是否应展平对象属性。 Setting it to false will retain complex object structure in LogProperties
property.将其设置为 false 将在LogProperties
属性中保留复杂的对象结构。
For more details, you could refer to this issue .更详细的可以参考这个issue 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.