mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Merge branch 'master' of https://github.com/Microsoft/sql-server-samples
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using NLog;
|
||||
using NLog.Web;
|
||||
using System.IO;
|
||||
|
||||
@@ -9,15 +10,22 @@ namespace ProductCatalog
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseIISIntegration()
|
||||
.UseNLog()
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
NLogBuilder.ConfigureNLog("nlog.config");
|
||||
try
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseIISIntegration()
|
||||
.UseNLog()
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
|
||||
host.Run();
|
||||
host.Run();
|
||||
} finally
|
||||
{
|
||||
LogManager.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ namespace ProductCatalog
|
||||
{
|
||||
public Startup(IHostingEnvironment env)
|
||||
{
|
||||
env.ConfigureNLog("nlog.config");
|
||||
// Deprecated way to initialize NLog form nlog.config, but works if you don't copy file to /bin.
|
||||
//env.ConfigureNLog("nlog.config");
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(env.ContentRootPath)
|
||||
@@ -86,12 +87,7 @@ namespace ProductCatalog
|
||||
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||
loggerFactory.AddDebug();
|
||||
loggerFactory.AddSerilog();
|
||||
|
||||
//add NLog to ASP.NET Core
|
||||
loggerFactory.AddNLog();
|
||||
NLog.LogManager.ThrowExceptions = true;
|
||||
NLog.LogManager.ThrowConfigExceptions = true;
|
||||
|
||||
|
||||
app.UseSession();
|
||||
app.UseStaticFiles();
|
||||
app.UseMvc(routes =>
|
||||
|
||||
@@ -61,4 +61,10 @@
|
||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="nlog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user