ipjohnson / Grace

Grace is a feature rich dependency injection container library
MIT License
336 stars 33 forks source link

MS Ext Logging filter configuration doesn't work with Grace #147

Closed krisztiankocsis closed 6 years ago

krisztiankocsis commented 6 years ago

Hi!

I've tried to reduce the code as much as possible to trigger the issue: When I activate Grace using UseGrace() + ConfigureContainer(), settings that are present in AppSettings.json regarding the logging filter level configuration, aren't applied.

When I comment out Grace and ConfigureContainer, it starts working -> dbug statements disappear.

I've attached my simple empty project. I can aid you if you need some more information. Environment: macOS High Sierra, .NET Core Runtime 2.0.5, SDK 2.1.4.

BR, Krisztian K. planny-grace-issue.zip

ipjohnson commented 6 years ago

Hi @krisztiankocsis

so I took a look and nothing really stood out as why it would work differently. That said I'll admit I don't use MS logging for asp.net core I usually pair it with something like nlog.

I'll see if I can take a deeper look this weekend but I'm not sure what specifically could cause this.

-Ian

ipjohnson commented 6 years ago

@krisztiankocsis I've upgraded to aspnetcore 2.0 at work and noticed the same thing. I'll be doing some more research and I'll post back when I figure it out.

krisztiankocsis commented 6 years ago

Ok, thanks!

ipjohnson commented 6 years ago

Sorry took me way to long to figure this out but the reason logging got turned on by default is because of auto registration. Long story short it's probably best to turn off auto registration for the whole "Microsoft" namespace

            scope.Configure(c =>
            {
                c.ExcludeTypeFromAutoRegistration("Microsoft.*");
            });
krisztiankocsis commented 6 years ago

Thanks for the help!