https://github.com/unitycontainer/nlog
Adapter for NLog
https://github.com/unitycontainer/nlog
Last synced: 7 months ago
JSON representation
Adapter for NLog
- Host: GitHub
- URL: https://github.com/unitycontainer/nlog
- Owner: unitycontainer
- License: apache-2.0
- Created: 2018-01-09T14:07:39.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-07T15:43:18.000Z (about 3 years ago)
- Last Synced: 2024-10-04T17:36:05.000Z (over 1 year ago)
- Language: C#
- Size: 41 KB
- Stars: 20
- Watchers: 6
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[](https://ci.appveyor.com/project/unitycontainer/nlog-9y7y3/branch/v5.x)
[](https://github.com/IoC-Unity/NLog/blob/master/LICENSE)
[](https://www.nuget.org/packages/Unity.NLog)
[](https://www.nuget.org/packages/Unity.NLog)
# NLog adapter for Unity container
Unity extension to integrate with popular [NLog](https://github.com/nlog/nlog) logger.
## Getting Started
- Reference the `Unity.NLog` package from NuGet.
```shell
Install-Package Unity.NLog
```
## Registration:
- Add `NLogExtension` extension to the container
```C#
container = new UnityContainer();
container.AddNewExtension();
```
- Where required add `ILogger` interface to resolved constructor.
```C#
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
```C#
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](https://www.contributor-covenant.org/) to clarify expected behavior in our community. For more information, see the [.NET Foundation Code of Conduct](https://www.dotnetfoundation.org/code-of-conduct)
## Contributing
See the [Contributing guide](https://github.com/unitycontainer/unity/blob/master/CONTRIBUTING.md) for more information.
## .NET Foundation
Unity Container is a [.NET Foundation](https://dotnetfoundation.org/projects/unitycontainer) project