#2235·serilog

Destructuring does not work on Android.NET in Release build when logging to Seq

Author: slepmogCreated May 7, 2026Updated Jul 16, 2026
Labelsbug

The problem: Logging to Seq from a Release build of an Android.NET application does not destructure objects.
Objects that do not have a custom .Destructure.ByTransforming<> policy will be logged as their class names, objects that do will be logged as JSON-like strings.

Logging from a Debug Android build works fine.
Logging from non-Android environments works fine too.

Reproduction Use the standard Visual Studio template for an Android application. This will create a blank .NET9 Android app. Install the Nuget packages: Serilog, Serilog.Sinks.Seq.
Replace the contents of public class MainActivity : Activity with:

csharp
private class ClassWithSpecialTransforming
{
    public int IntProperty { get; set; }
    public string StringProperty { get; set; }
}

public class ClassWithoutSpecialTransforming
{
    public int IntProperty { get; set; }
    public string StringProperty { get; set; }
}

protected override void OnCreate(Bundle? savedInstanceState)
{
    base.OnCreate(savedInstanceState);

    SetContentView(Resource.Layout.activity_main);


    Serilog.Log.Logger = new Serilog.LoggerConfiguration()
        .Destructure.ByTransforming<ClassWithSpecialTransforming>(c => new { c.IntProperty, c.StringProperty })
        .WriteTo.Seq(
            serverUrl: "your.local.seq.server:5341"
        )
        .CreateLogger();


    Serilog.Log.Logger
        .ForContext("AdditionalObject", new ClassWithSpecialTransforming() { IntProperty = 42, StringProperty = "forty two" }, destructureObjects: true)
        .ForContext("MainObject", new ClassWithoutSpecialTransforming() { IntProperty = 42, StringProperty = "not forty two" }, destructureObjects: true)
        .Information("This is the object.");

    Serilog.Log.CloseAndFlush();
}

Start the application on the emulator (or a real device, does not matter) in the Debug configuration. Observe that the following entry appears in Seq (as copied from Seq via Export - Copy raw JSON):

json
{
  "@t": "2026-05-07T15:29:53.6870881Z",
  "@mt": "This is the object.",
  "@m": "This is the object.",
  "@i": "cb84e0d5",
  "AdditionalObject": {
    "IntProperty": 42,
    "StringProperty": "forty two"
  },
  "MainObject": {
    "$type": "ClassWithoutSpecialTransforming",
    "IntProperty": 42,
    "StringProperty": "not forty two"
  }
}

This entry is correct. Both objects are destructured.

Now switch the application to the Release configuration and run it again.
Observe that the following entry appears in Seq:

json
{
  "@t": "2026-05-07T15:31:40.4311589Z",
  "@mt": "This is the object.",
  "@m": "This is the object.",
  "@i": "cb84e0d5",
  "AdditionalObject": "{ IntProperty = 42, StringProperty = forty two }",
  "MainObject": "SerilogTestFromAndroid.MainActivity+ClassWithoutSpecialTransforming"
}

This entry is wrong. AdditionalObject is a JSON-like string, MainObject is represented by its class name.

Expected behavior Both times the Seq entry looks like example 1, with the objects destructured into actual JSON objects.

Relevant package, tooling and runtime versions Serilog 4.3.0 and 4.3.1, Seq Sink 9.0.0, Android.NET 9, Visual Studio 2022