autofac-serilog-integration
autofac-serilog-integration copied to clipboard
Injection doesn't work for `AutofacChildLifetimeScopeConfigurationAdapter`
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:
- Do not configure child container at all and missing
UseSerilog
- Add
UseSerilog
only - Add
ConfigureContainer
call from the sample above - 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.