I'm trying to track down whats going on inside some of my components, each of which controls a custom mvc route with a custom handler.
How do I access or obtain access to the serilog logger (from within the component) which outputs to /app_data/logs? I have tried just injecting an ILogger, but that fails horribly and prevents the site from booting.
Logging from Component
Hi
I'm trying to track down whats going on inside some of my components, each of which controls a custom mvc route with a custom handler.
How do I access or obtain access to the serilog logger (from within the component) which outputs to /app_data/logs? I have tried just injecting an ILogger, but that fails horribly and prevents the site from booting.
/Allan
Hi Allan,
Please can you share the code as iLogger is the way to go and it worked for us.
Regards,
Shaishav
The above will fail with the following:
ystem.InvalidOperationException: Unresolved dependency [Target Type: An.Web.Components.ProductRouteComponent], [Parameter: logger(ClientDependency.Core.Logging.ILogger)], [Requested dependency: ServiceType:ClientDependency.Core.Logging.ILogger, ServiceName:]
I have also tried adding the Microsoft.Extensions.Logging.Abstractions package and used the ILogger
Hi Allan. I just had the same issue in a Surface Controller, which went away when I added this using statement: using Umbraco.Core.Logging.
Yes, as HBSequence is onto, you need to specify the correct namespace.
With the various DLLs shipping with Umbraco, there are a few different interfaces called
ILogger
.From the stack trace posted, it seems that you've used ClientDependency's
ILogger
instead of Umbraco'sILogger
.The correct namespace is
Umbraco.Core.Logging
.is working on a reply...