ASP.NET Core Serilog至loggly不显示JSON属性

发布于 2025-02-06 07:20:20 字数 690 浏览 4 评论 0原文

我们的应用程序使用serilog nuget软件包将日志写入loggly,我正在使用globallogcontext添加这样的自定义属性:

using (GlobalLogContext.PushProperty("TransactionActivityId", activityId))
{
    _logger.LogInformation("Test log message");
}

进行logger设置了logger

.UseSerilog((context, loggerConfiguration) => loggerConfiguration
    .ReadFrom.Configuration(context.Configuration)
    .Enrich.FromGlobalLogContext())

我们还通过在loggly中 “原始消息”部分,但自定义属性未显示在JSON部分中。

为了使loggly在JSON部分中显示此属性必须做什么?

Our application uses the Serilog NuGet package to write logs to Loggly, and I am using GlobalLogContextto add a custom property like this:

using (GlobalLogContext.PushProperty("TransactionActivityId", activityId))
{
    _logger.LogInformation("Test log message");
}

We also set up the logger by doing

.UseSerilog((context, loggerConfiguration) => loggerConfiguration
    .ReadFrom.Configuration(context.Configuration)
    .Enrich.FromGlobalLogContext())

In Loggly, I see the property in the "raw message" section, but the custom property is not showing up in the json section.
enter image description here

What has to be done in order for Loggly to show this property in the json section?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文