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
));
});
App works locally on Windows but fails on publish to Azure Linux environment
var conn = ...
• 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.