Skip to content

Commit

Permalink
remove ASP.NET dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
304NotModified committed Jan 15, 2017
1 parent f9c979e commit 5bc552e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
"version": "1.0.0-preview2-1-003177"
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Helpers for ASP.NET Core
/// Helpers for .NET Core
/// </summary>
public static class AspNetExtensions
public static class ConfigureExtensions
{
/// <summary>
/// Enable NLog as logging provider in ASP.NET Core.
/// Enable NLog as logging provider in .NET Core.
/// </summary>
/// <param name="factory"></param>
/// <returns></returns>
Expand All @@ -23,7 +22,7 @@ public static ILoggerFactory AddNLog(this ILoggerFactory factory)
}

/// <summary>
/// Enable NLog as logging provider in ASP.NET Core.
/// Enable NLog as logging provider in .NET Core.
/// </summary>
/// <param name="factory"></param>
/// <param name="options">NLog options</param>
Expand All @@ -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))
{
Expand All @@ -59,9 +58,15 @@ public static ILoggerFactory AddNLog(this ILoggerFactory factory, NLogProviderOp
/// </summary>
/// <param name="env"></param>
/// <param name="configFileRelativePath">relative path to NLog configuration file.</param>
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);
}

Expand Down
17 changes: 10 additions & 7 deletions src/NLog.Extensions.Logging/project.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"]}
}
}
}

0 comments on commit 5bc552e

Please sign in to comment.