-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UseNLogHost() to be used on IHostBuilder (#11604)
- Loading branch information
Showing
2 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/OrchardCore/OrchardCore.Logging.NLog/HostBuilderExtensions.cs
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,24 @@ | ||
using System.IO; | ||
using Microsoft.Extensions.Hosting; | ||
using NLog; | ||
using NLog.LayoutRenderers; | ||
using NLog.Web; | ||
|
||
namespace OrchardCore.Logging; | ||
|
||
public static class HostBuilderExtensions | ||
{ | ||
public static IHostBuilder UseNLogHost(this IHostBuilder builder) | ||
{ | ||
LayoutRenderer.Register<TenantLayoutRenderer>(TenantLayoutRenderer.LayoutRendererName); | ||
builder.UseNLog(); | ||
builder.ConfigureAppConfiguration((context, _) => | ||
{ | ||
var environment = context.HostingEnvironment; | ||
environment.ConfigureNLog($"{environment.ContentRootPath}{Path.DirectorySeparatorChar}NLog.config"); | ||
LogManager.Configuration.Variables["configDir"] = environment.ContentRootPath; | ||
}); | ||
|
||
return builder; | ||
} | ||
} |
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