Add NLog Provider to ILoggerFactory

I am trying to add NLog as a provider to my logger factory in my startup.cs file, but I cannot add it. All the examples I've seen do this:

loggerFactory.AddNLog(new global::NLog.LogFactory());

I use:

"Microsoft.Framework.Logging": "1.0.0-beta2"

From what I can say in github examples etc., this no longer exists:

"Microsoft.Framework.Logging.NLog": "1.0.0-*"

So, I would like to know that it has been replaced ("NLog": "3.2.0.0"?), And what is the correct way to add the NLog provider to my boot file?

Thank!

+4
source share
1 answer

The ASP.NET GitHub repository shows an example of registration: https://github.com/aspnet/Logging/tree/dev/samples/SampleApp

NLog: https://github.com/aspnet/Logging/tree/dev/src/Microsoft.Framework.Logging.NLog

project.json : https://github.com/aspnet/Logging/blob/dev/samples/SampleApp/project.json

{
    "dependencies": {
        "Microsoft.Framework.Logging": "1.0.0-*",
        "Microsoft.Framework.Logging.Console": "1.0.0-*"
    },
    "frameworks": {
        "aspnet50": {
            "dependencies": {
                "Microsoft.Framework.Logging.NLog": "1.0.0-*"
            }
        },
        "aspnetcore50": {
            "dependencies": {
                "System.Console": "4.0.0-beta-*"
            }
        }
    }
}

project.json NLog NLog:

{
    "version": "1.0.0-*",
    "dependencies": {
        "Microsoft.Framework.Logging": "1.0.0-*",
        "NLog": "3.1.0"
    },
    "frameworks": {
        "net45": { },
        "aspnet50": { }
    }
}

, NLog aspnet50 (.NET 4.x), aspnetcore50 (Core CLR).

, , NLog , ASP.NET , .

+2

All Articles