autofac-serilog-integration icon indicating copy to clipboard operation
autofac-serilog-integration copied to clipboard

Injection doesn't work for `AutofacChildLifetimeScopeConfigurationAdapter`

Open sguryev opened this issue 4 years ago • 0 comments

I have an application with the child scope built using this manual: https://github.com/autofac/Documentation/blob/master/docs/integration/aspnetcore.rst#using-a-child-scope-as-a-root

I have this code for registering Serilog in the child container

public void ConfigureContainer(AutofacChildLifetimeScopeConfigurationAdapter adapter)
{
    adapter.Add(builder =>
    {
        builder.RegisterLogger();
    });
}

Parent container has builder.RegisterLogger(); as well. Context is missing in all cases:

  1. Do not configure child container at all and missing UseSerilog
  2. Add UseSerilog only
  3. Add ConfigureContainer call from the sample above
  4. 2nd + 3rd options together.

Sample log entry with the missing context between <>: 2021-02-03 16:53:37Z [4] DBG <> User login was denied. Reason = InvalidUsernameOrPassword.

sguryev avatar Feb 03 '21 17:02 sguryev