Skip to content

Publish to Linux on Azure fails #65

Description

@stokara

App works locally on Windows but fails on publish to Azure Linux environment

var conn = ...

loggerConfiguration
    .Enrich.FromLogContext()
    .Enrich.WithEnvironmentName()
    .Enrich.WithProperty("ApplicationName", "EligibilityApi")
    .Enrich.WithThreadId()
    //.WriteTo.Console()
    .WriteTo.SqlServer(cfg => {
        cfg.ConnectionString = conn;
        cfg.AddPropertyMapping("EnvironmentName");
        cfg.AddPropertyMapping("ApplicationName");

• Runtime: .NET 10, linux-x64
• Exception 1: BadImageFormatException: Bad IL range
• Exception 2: CultureNotFoundException: b__107_7 (the < eaten by HTML rendering)

workaround

The Fluent .AddPropertyMapping is where the error is being thrown but changing to .Add() removes the error.

    .WriteTo.SqlServer(cfg => {
        cfg.ConnectionString = conn;
        cfg.Mappings.Add(new ColumnMapping<LogEvent>(
            ColumnName: "EnvironmentName",
            ColumnType: typeof(string),
            GetValue: logEvent => logEvent.Properties.GetValueOrDefault("EnvironmentName")?.ToString()?.Trim('"'),
            Nullable: true,
            Size: 500
        ));
        cfg.Mappings.Add(new ColumnMapping<LogEvent>(
            ColumnName: "ApplicationName",
            ColumnType: typeof(string),
            GetValue: _ => "EligibilityApi",
            Nullable: true,
            Size: 500
        ));
    });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions