Comments (3)
I've encountered the same problem when trying to use the Autofac serilog integration within an ASP.NET Core 2.1 application - when injecting the ILogger into a Controller, {SourceContext}
is blank, but when injecting it into any other class, {SourceContext}
works as expected.
2018-10-27 08:56:17.919 INF [] - This is a log line from a controller.
2018-10-27 08:56:17.927 INF [SerilogSample.Test] - This is a log line from a class.
I've put together a basic project that illustrates the problem: @alvaromarithompson/serilog-bug-sample
from autofac-serilog-integration.
Hi @urajkovic - thanks for the report.
I'm not sure how to approach this, I'm not up-to-date with the Autofac integration for ASP.NET Core 2, so would need some time to debug.
Help/PRs welcome, if anyone's able to take a look.
Thanks again!
from autofac-serilog-integration.
The reason for this is something that we already explained. While controller’s constructor dependencies would be resolved by MVC from the IServiceProvider (so in our case an Autofac adapter), the instance of the controller itself (and its disposal too) is created and owned by the framework, not by the container.
The quickest workaround is to AddControllersAsServices
in the configure services method
from autofac-serilog-integration.
Related Issues (20)
- any plan to get this one supported .net core? HOT 2
- New version of package with serilog 2.x dependency HOT 1
- Reference for breaking changes between 1.x and 2.x? HOT 2
- Customization of the ILogger dependency configuration HOT 5
- Method not found ModuleRegistration failed HOT 1
- SourceContext not being injected into BackgroundService (net core 3.1 app autofac5) HOT 1
- Performance overhead for components not consuming ILogger HOT 2
- Autofac 6 migration HOT 1
- Unable to install the package in project framework targeted 4.0 HOT 1
- System.MissingMethodException: Method not found: 'Void Autofac.Core.IComponentRegistration.add_Preparing HOT 2
- Not working with Autofac 6.X.X HOT 1
- MissingMethodException in AutofacSerilogIntegration.ContextualLoggingModule.AttachToComponentRegistration HOT 2
- Injection doesn't work for `AutofacChildLifetimeScopeConfigurationAdapter`
- AutofacSerilogIntegration.dll has the wrong file version HOT 1
- Using ILogger from 'Microsoft.Extensions.Logging.Abstractions' HOT 2
- Support AutoFac 9, Serilog 3, .NET 4.8.1 HOT 1
- Doesn't add SourceContext in ASP.Net 5 controllers with ILogger injected HOT 7
- Custom ILogger registration? HOT 5
- ContextualLoggingModule gets registered twice when using Autofac's assembly scanning HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autofac-serilog-integration.