Skip to content

Commit b1ba3de

Browse files
committed
Use more colorful console sink for NHibernate.Example.Web.
1 parent 6446928 commit b1ba3de

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/NHibernate.Example.Web/NHibernate.Example.Web.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
1515
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.0" PrivateAssets="All" />
1616
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
17+
<PackageReference Include="Serilog.AspNetCore" Version="2.0.0" />
18+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.0" />
1719
</ItemGroup>
1820

1921
<ItemGroup>

src/NHibernate.Example.Web/Program.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,29 @@
77
using Microsoft.AspNetCore.Hosting;
88
using Microsoft.Extensions.Configuration;
99
using Microsoft.Extensions.Logging;
10+
using Serilog;
11+
using Serilog.Events;
1012

1113
namespace NHibernate.Example.Web
1214
{
1315
public class Program
1416
{
1517
public static void Main(string[] args)
1618
{
19+
Log.Logger = new LoggerConfiguration()
20+
.MinimumLevel.Debug()
21+
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
22+
.Enrich.FromLogContext()
23+
.WriteTo.Console()
24+
.CreateLogger();
25+
1726
BuildWebHost(args).Run();
1827
}
1928

2029
public static IWebHost BuildWebHost(string[] args) =>
2130
WebHost.CreateDefaultBuilder(args)
2231
.UseStartup<Startup>()
32+
.UseSerilog()
2333
.Build();
2434
}
2535
}

0 commit comments

Comments
 (0)