-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
64 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#if NETSTANDARD2_0 | ||
|
||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using NLog.Common; | ||
using NLog.Config; | ||
|
||
namespace NLog.Web | ||
{ | ||
|
||
|
||
/// <summary> | ||
/// NLog helper for ASP.NET Standard 2 | ||
/// </summary> | ||
public static class NLogBuilder | ||
{ | ||
/// <summary> | ||
/// Register NLog.Web.AspNetCore, so so <extension> in NLog's config isn't needed. | ||
/// </summary> | ||
internal static void RegisterNLogWebAspNetCore() | ||
{ | ||
try | ||
{ | ||
InternalLogger.Debug("Registering NLog.Web.AspNetCore"); | ||
ConfigurationItemFactory.Default.RegisterItemsFromAssembly(typeof(AspNetExtensions).GetTypeInfo().Assembly); | ||
} | ||
catch (Exception ex) | ||
{ | ||
InternalLogger.Error(ex, "Registering NLog.Web.AspNetCore failed"); | ||
} | ||
|
||
} | ||
|
||
/// <summary> | ||
/// Configure NLog | ||
/// </summary> | ||
/// <param name="fileName">Path to NLog configuration file, e.g. nlog.config. </param>> | ||
/// <returns>LogFactory to get loggers, add events etc</returns> | ||
public static LogFactory ConfigureNLog(string fileName) | ||
{ | ||
RegisterNLogWebAspNetCore(); | ||
return ConfigureNLog(new XmlLoggingConfiguration(fileName)); | ||
} | ||
|
||
/// <summary> | ||
/// Configure NLog | ||
/// </summary> | ||
/// <param name="configuration"></param> | ||
/// <returns>LogFactory to get loggers, add events etc</returns> | ||
public static LogFactory ConfigureNLog(LoggingConfiguration configuration) | ||
{ | ||
RegisterNLogWebAspNetCore(); | ||
LogManager.Configuration = configuration; | ||
return LogManager.LogFactory; | ||
} | ||
} | ||
} | ||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters