Adapter for NLog
Перейти к файлу
Eugene Sadovoi 235fc811a6
Create FUNDING.yml
2021-06-14 10:07:17 -07:00
.github Create FUNDING.yml 2021-06-14 10:07:17 -07:00
src Copyright © .NET Foundation and Contributors. 2020-05-13 15:51:33 -07:00
tests Update version 2020-04-20 22:17:56 -07:00
.gitignore Initial commit 2018-01-09 09:07:39 -05:00
LICENSE Copyright © .NET Foundation and Contributors. 2020-05-13 15:51:33 -07:00
README.md Adding .Net Foundation links 2020-05-14 13:38:11 -07:00
appveyor.yml Fixing test 2019-01-24 18:28:48 -05:00
package.props Releasing 5.11.1 2019-06-20 16:10:33 -04:00
package.sln Added projects 2018-01-10 23:58:50 -05:00

README.md

Build status License NuGet NuGet

NLog adapter for Unity container

Unity extension to integrate with popular NLog logger.

Getting Started

  • Reference the Unity.NLog package from NuGet.
Install-Package Unity.NLog

Registration:

  • Add NLogExtension extension to the container
container = new UnityContainer();
container.AddNewExtension<NLogExtension>();
  • Where required add ILogger interface to resolved constructor.
public class LoggedType
{
    public LoggedType(ILogger log)
    {
    }
  ...
}
  • 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
var ext = new NLogExtension{
    GetName = (t, n) => t.Name
};
container.AddExtension(ext);
  • Log normally...

Code of Conduct

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

Contributing

See the Contributing guide for more information.

.NET Foundation

Unity Container is a .NET Foundation project