Unity extension to integrate with popular NLog logger.
- Reference the
Unity.NLogpackage from NuGet.
Install-Package Unity.NLog- Add
NLogExtensionextension to the container
container=newUnityContainer();container.AddNewExtension<NLogExtension>();- Where required add
ILoggerinterface to resolved constructor.
publicclassLoggedType{publicLoggedType(ILoggerlog){}
...}- If you want to custom the extension (In this case, get only the class name instead of the full name), you have to instantiate NLogExtension to set properties and add this extension to Unity
varext=newNLogExtension{GetName=(t,n)=>t.Name};container.AddExtension(ext);- Log normally...
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the .NET Foundation Code of Conduct
See the Contributing guide for more information.
Unity Container is a .NET Foundation project