diff --git a/global.json b/global.json index e793049c..8b163c58 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "projects": [ "src", "test" ], "sdk": { - "version": "1.0.0-preview2-003121" + "version": "1.0.0-preview2-1-003177" } } diff --git a/src/NLog.Extensions.Logging/AspNetExtensions.cs b/src/NLog.Extensions.Logging/ConfigureExtensions.cs similarity index 78% rename from src/NLog.Extensions.Logging/AspNetExtensions.cs rename to src/NLog.Extensions.Logging/ConfigureExtensions.cs index 2a709430..3e4004a5 100644 --- a/src/NLog.Extensions.Logging/AspNetExtensions.cs +++ b/src/NLog.Extensions.Logging/ConfigureExtensions.cs @@ -1,19 +1,18 @@ using System; using System.IO; using System.Reflection; -using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Logging; using NLog.Config; namespace NLog.Extensions.Logging { /// - /// Helpers for ASP.NET Core + /// Helpers for .NET Core /// - public static class AspNetExtensions + public static class ConfigureExtensions { /// - /// Enable NLog as logging provider in ASP.NET Core. + /// Enable NLog as logging provider in .NET Core. /// /// /// @@ -23,7 +22,7 @@ public static ILoggerFactory AddNLog(this ILoggerFactory factory) } /// - /// Enable NLog as logging provider in ASP.NET Core. + /// Enable NLog as logging provider in .NET Core. /// /// /// NLog options @@ -45,7 +44,7 @@ public static ILoggerFactory AddNLog(this ILoggerFactory factory, NLogProviderOp //ignore } - LogManager.AddHiddenAssembly(typeof(AspNetExtensions).GetTypeInfo().Assembly); + LogManager.AddHiddenAssembly(typeof(ConfigureExtensions).GetTypeInfo().Assembly); using (var provider = new NLogLoggerProvider(options)) { @@ -59,9 +58,15 @@ public static ILoggerFactory AddNLog(this ILoggerFactory factory, NLogProviderOp /// /// /// relative path to NLog configuration file. - public static void ConfigureNLog(this IHostingEnvironment env, string configFileRelativePath) + public static void ConfigureNLog(this ILoggerFactory env, string configFileRelativePath) { - var fileName = Path.Combine(env.ContentRootPath, configFileRelativePath); +#if NETCORE + var rootPath = System.AppContext.BaseDirectory; +#else + var rootPath = AppDomain.CurrentDomain.BaseDirectory; +#endif + + var fileName = Path.Combine(rootPath, configFileRelativePath); ConfigureNLog(fileName); } diff --git a/src/NLog.Extensions.Logging/project.json b/src/NLog.Extensions.Logging/project.json index 1ced5ca7..758bdfda 100644 --- a/src/NLog.Extensions.Logging/project.json +++ b/src/NLog.Extensions.Logging/project.json @@ -1,9 +1,9 @@ { - "version": "1.0.0-rtm-alpha5", + "version": "1.0.0-rtm-beta1", "description": "NLog provider for Microsoft.Extensions.Logging", "authors": [ "Microsoft", "Julian Verdurmen" ], "packOptions": { - "tags": [ "NLog", "Microsoft.Extensions.Logging", "Microsoft.Framework.Logging", "log", "logfiles", "aspnet5", "dnx" ], + "tags": [ "NLog", "Microsoft.Extensions.Logging", "log", "logfiles", "netcore", "nlog" ], "projectUrl": "https://github.com/NLog/NLog.Extensions.Logging", "licenseUrl": "https://github.com/NLog/NLog.Extensions.Logging/blob/master/LICENSE", "iconUrl": "http://nlog-project.org/NConfig.png", @@ -18,23 +18,26 @@ "keyFile": "NLog.snk" }, "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "1.0.0", - "Microsoft.AspNetCore.Hosting": "1.0.0" + "Microsoft.Extensions.Logging.Abstractions": "1.0.0" }, "frameworks": { "net451": { "frameworkAssemblies": { "System.Xml": "4.0.0.0", + "System.Runtime": "4.0.10.0", "System.Xml.Serialization": "4.0.0.0" + }, "dependencies": { - "NLog": "4.3.11" + "NLog": "4.4.1" } }, "netstandard1.3": { "dependencies": { - "NLog": "5.0.0-beta03" - } + "NLog": "5.0.0-beta04", + "System.AppContext": "4.3.0" + }, + "buildOptions": {"define": ["NETCORE"]} } } }