Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Issue with resolved ILogger in Autofac 4.6.1+ #949

Closed
danjohnso opened this issue Nov 8, 2018 · 3 comments
Closed

Issue with resolved ILogger in Autofac 4.6.1+ #949

danjohnso opened this issue Nov 8, 2018 · 3 comments

Comments

@danjohnso
Copy link

danjohnso commented Nov 8, 2018

I am using Autofac.AspNetCore.Multitenant and Autofac.Extensions.DependencyInjection in an application and after upgrading the Autofac.Extensions.DependencyInjection package, my logs disappeared. Long story short, something between 4.6.0 and 4.6.1 breaks logging in the ASPNET core pipeline once you get to the controller level. I can see action filter and middlewar logging, but controller on down I get nothing. I backed out the Autofac.Extensions.DependencyInjection update (just a dependency update, no code changes) and logs came back. Since the only change on that package was autofac version, I slowly bumped up the autofac version on the project explicitly (was relying on dependency minimums of the other 2 packages before). 4.6.0 worked still, but at 4.6.1 logs disappeared again. I did try going all the way up to the latest version in case there was a regression that got fixed, but everything above 4.6.0 has this issue. There are no exceptions, canceled threads etc. When debugging, I can see the logger injected and I can "write" logs, but they are black holed and never appear in the outputs. I tried a couple logging destinations to try to eliminate permission issues, but nothing in the console, debug windows of VS or log file.

I'm happy to help track this down but I am out of ideas as to where to look or what would be helpful to the maintainers in triaging an issue like this. Here are the packages in my project when it breaks:

<PackageReference Include="Autofac" Version="4.6.1" /> <---change this to 4.6.0 and everything is fine
<PackageReference Include="Autofac.AspNetCore.Multitenant" Version="1.0.2" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.3.0" />
<PackageReference Include="IdentityModel" Version="3.8.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.5" PrivateAssets="All" />
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.0.138" />
<PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.0.138" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Serilog.Enrichers.Demystify" Version="0.1.0-dev-00016" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.2" />
<PackageReference Include="Serilog.Formatting.Compact" Version="1.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
<PackageReference Include="Destructurama.Attributed" Version="2.0.0" />
@tillig
Copy link
Member

tillig commented Nov 8, 2018

We're going to need a minimal repro to help out with this. You can look at the release notes to see what's changed, but without something minimal (e.g., no IdentityModel, no MiniProfiler, etc.) to see what's up, there's no way to pinpoint it. I'm personally using Autofac 4.8.1 with logging in .NET Core without issues.

@danjohnso
Copy link
Author

Spent most of today working on this, but I wasn't able to get this to repro in a small project that is setup the same. I got my main project working by commenting out entity framework registrations (AddDbContextPool), but that didn't seem to affect the test project. I took a closer look at the Logger being injected into my controller and in the working project it is a SerilogLogger, but the broken version it is the Microsoft.Extensions.Logger which doesn't actually have any sinks registered to it since I use Serilog everywhere. #847 seems the most closely related in the 4.6.1 release, but I am not sure how EF Core registrations would affect the things I am seeing.

For now, I found I can explicitly register an ILoggerFactory in my child tenant scopes and logger is being injected correctly. No idea why that fixes this...maybe after I get over this ciold I will be able to see what was different in my test project and repro better, but for now I have a work around. I think I will just leave this open for now in case anyone else runs into something similar and we can pin it down more.

@tillig
Copy link
Member

tillig commented Dec 11, 2018

Without a repro there's nothing we can do here. I'm going to close this; if there's a small repro where we can see the issue, we can reopen as needed.

@tillig tillig closed this as completed Dec 11, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants