Skip to content

Where is WithEcsHttpContext defined and how to put this in appsettings.json "Enrich" configuration? #494

@khteh

Description

@khteh

I am using Elastic.CommonSchema.Serilog 8.12.3 and get the following build error:

'LoggerEnrichmentConfiguration' does not contain a definition for 'WithEcsHttpContext' and no accessible extension method 'WithEcsHttpContext' accepting a first argument of type 'LoggerEnrichmentConfiguration' could be found (are you missing a using directive or an assembly reference?)

How to put the following

config.ReadFrom.Configuration(ctx.Configuration).Enrich.WithEcsHttpContext(ctx.Configuration.Get<HttpContextAccessor>());

into appsettings.json "Enrich" configuration?

        "Enrich": [
            "FromLogContext",
            "WithMachineName",
            "WithThreadId"
        ],

Is the following appsettings.json still relevant with the latest development in ElasticSearch JSON formatter?

        "WriteTo": [
            {
                "Name": "File",
                "Args": {
                    "Args": {
                        "outputTemplate": "{Timestamp} {Level} {EventId} {Message:j} {Properties}{NewLine}{Exception}{NewLine}"
                    },
                    "Enrich": [
                        "FromLogContext"
                    ],
                    "path": "/var/log/aspnetcore/log",
                    "rollingInterval": "Day",
                    "retainedFileCountLimit": 3,
                    "formatter": "Serilog.Formatting.Elasticsearch.ElasticsearchJsonFormatter, Serilog.Formatting.Elasticsearch, Version=0.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10"
                }
            }
        ]

If not, how should I change it to?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions