I have a custom membership provider that implement certain membership provider methods.
I'm trying to create log messages inside those methods.
According to the doc, this should be enough:
Logger.Info<MyApiController>("We are saying hello to {Name}", name);
However, I can't find Logger in the Umbraco.Core.Logging namespace.or any other namespaces.
Is there a way I can create logs from this file, do I have to create my own logger, what would the correct solution be for creating logs here.
I think in the example Logger has been injected into the class - so in the wonderful world of dependency injection. the main constructor of the class will take either a ILogger of IProfilingLogger argument, and that is the logger.
If for reasons you don't think you can use Dependency Injection (but do try), then you can access the Singleton version of the logger in Current.Logger
(it is recommended you avoid the singleton for reasons)
Logging in Umbraco 8. The correct way ?
Hi, This may be a stupid question but, anyway.
I have a custom membership provider that implement certain membership provider methods. I'm trying to create log messages inside those methods. According to the doc, this should be enough:
However, I can't find Logger in the Umbraco.Core.Logging namespace.or any other namespaces.
Is there a way I can create logs from this file, do I have to create my own logger, what would the correct solution be for creating logs here.
Thank you!
Hi,
I think in the example Logger has been injected into the class - so in the wonderful world of dependency injection. the main constructor of the class will take either a
ILogger
ofIProfilingLogger
argument, and that is the logger.If for reasons you don't think you can use Dependency Injection (but do try), then you can access the Singleton version of the logger in
Current.Logger
(it is recommended you avoid the singleton for reasons)
Hi Kevin, Thank you for your reply.
I can't use DI here as the MembershipProvider class is not built via container. I get this error when trying to do so: https://static.md/72d6943a5ee0c73e915cf96b1b57723d.png
But instead, I've used
This also shows the error in backoffice.
I'm not sure if that is a good practice or if there is any better solution, please let me know if you are aware of any.
Thanks for your help.
is working on a reply...