-
-
Notifications
You must be signed in to change notification settings - Fork 23
Description
I ran into an issue when using Serilog with Dotnettency but the same problem occurs with NLog as well.
Steps to Reproduce
-
Install Serilog (https://github.com/serilog/serilog-aspnetcore) into the Authentication-Sample App (https://github.com/dazinator/Dotnettency.Samples/tree/aspnetcore20/src/Sample.Authentication)
` public class Program
{
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateLogger();BuildWebHost(args).Run(); } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseUrls("http://*:5000", "http://*:5001", "http://*:5002", "http://*:5003", "http://*:5004") .UseSerilog() .Build();}`
-
Start the App
Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = AutofacTenantContainerAdaptor (ReflectionActivator), Services = [Dotnettency.Container.ITenantContainerAdaptor, System.IServiceProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = Logger1 (ReflectionActivator), Services = [Microsoft.Extensions.Logging.ILogger1[[Dotnettency.Container.AutofacTenantContainerAdaptor, Dotnettency.Container.Autofac, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = ILoggerFactory (DelegateActivator), Services = [Microsoft.Extensions.Logging.ILoggerFactory], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> Circular component dependency detected: Dotnettency.Container.AutofacTenantContainerAdaptor -> Microsoft.Extensions.Logging.Logger1[[Dotnettency.Container.AutofacTenantContainerAdaptor, Dotnettency.Container.Autofac, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -> Microsoft.Extensions.Logging.ILoggerFactory -> Dotnettency.Container.AutofacTenantContainerAdaptor. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.) ---> Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = Logger1 (ReflectionActivator), Services = [Microsoft.Extensions.Logging.ILogger1[[Dotnettency.Container.AutofacTenantContainerAdaptor, Dotnettency.Container.Autofac, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = ILoggerFactory (DelegateActivator), Services = [Microsoft.Extensions.Logging.ILoggerFactory], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> Circular component dependency detected: Dotnettency.Container.AutofacTenantContainerAdaptor -> Microsoft.Extensions.Logging.Logger1[[Dotnettency.Container.AutofacTenantContainerAdaptor, Dotnettency.Container.Autofac, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -> Microsoft.Extensions.Logging.ILoggerFactory -> Dotnettency.Container.AutofacTenantContainerAdaptor. (See inner exception for details.) (See inner exception for details.) ---> Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = ILoggerFactory (DelegateActivator), Services = [Microsoft.Extensions.Logging.ILoggerFactory], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> Circular component dependency detected: Dotnettency.Container.AutofacTenantContainerAdaptor -> Microsoft.Extensions.Logging.Logger1[[Dotnettency.Container.AutofacTenantContainerAdaptor, Dotnettency.Container.Autofac, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -> Microsoft.Extensions.Logging.ILoggerFactory -> Dotnettency.Container.AutofacTenantContainerAdaptor. (See inner exception for details.) ---> Autofac.Core.DependencyResolutionException: Circular component dependency detected: Dotnettency.Container.AutofacTenantContainerAdaptor -> Microsoft.Extensions.Logging.Logger1[[Dotnettency.Container.AutofacTenantContainerAdaptor, Dotnettency.Container.Autofac, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -> Microsoft.Extensions.Logging.ILoggerFactory -> Dotnettency.Container.AutofacTenantContainerAdaptor.
at Autofac.Core.Resolving.CircularDependencyDetector.CheckForCircularDependency(IComponentRegistration registration, Stack`1 activationStack, Int32 callDepth)
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context, IEnumerable`1 parameters)
at Autofac.Extensions.DependencyInjection.AutofacRegistration.<>c__DisplayClass3_0.b__0(IComponentContext context, IEnumerable`1 parameters) in C:\projects\autofac-extensions-dependencyinjection\src\Autofac.Extensions.DependencyInjection\AutofacRegistration.cs:line 187
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
--- End of inner exception stack trace ---
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
--- End of inner exception stack trace ---
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
--- End of inner exception stack trace ---
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context, IEnumerable`1 parameters)
at Dotnettency.AutofacContainerBuilderOptionsExtensions.<>c__DisplayClass0_0`1.b__0()
at Dotnettency.Container.AdaptedContainerBuilderOptions`1.<.ctor>b__0_0()
at Dotnettency.MultitenancyServiceCollectionExtensions.AddMultiTenancy[TTenant](IServiceCollection serviceCollection, Action`1 configure)
at Dotnettency.IServiceCollectionExtensions.AddAspNetCoreMultiTenancy[TTenant](IServiceCollection serviceCollection, Action`1 configure)
at Sample.Authentication.Startup.ConfigureServices(IServiceCollection services) in D:\Samples\Dotnettency.Samples\src\Sample.Authentication\Startup.cs:line 18
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()