Skip to content

Commit 5282909

Browse files
Merge pull request dotnet-architecture#45 from dotnet-architecture/dev
Added serilog
2 parents 9788f09 + fa0b1a7 commit 5282909

30 files changed

Lines changed: 155 additions & 4 deletions

File tree

src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.AspNetCore.App" />
1313
<PackageReference Include="Ocelot" Version="12.0.1" />
14+
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
15+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
1416
</ItemGroup>
1517
</Project>

src/ApiGateways/ApiGw-Base/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.Extensions.Configuration;
99
using Microsoft.Extensions.Logging;
1010
using Microsoft.Extensions.DependencyInjection;
11+
using Serilog;
1112

1213
namespace OcelotApiGw
1314
{
@@ -23,7 +24,14 @@ public static IWebHost BuildWebHost(string[] args)
2324
IWebHostBuilder builder = WebHost.CreateDefaultBuilder(args);
2425
builder.ConfigureServices(s => s.AddSingleton(builder))
2526
.ConfigureAppConfiguration(ic => ic.AddJsonFile(Path.Combine("configuration", "configuration.json")))
26-
.UseStartup<Startup>();
27+
.UseStartup<Startup>()
28+
.UseSerilog((builderContext, config) =>
29+
{
30+
config
31+
.MinimumLevel.Information()
32+
.Enrich.FromLogContext()
33+
.WriteTo.Console();
34+
});
2735
IWebHost host = builder.Build();
2836
return host;
2937
}

src/ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="Microsoft.AspNetCore.App" />
16+
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
17+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
1618
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
1719
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.1.0" />
1820
</ItemGroup>

src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.AspNetCore.Hosting;
88
using Microsoft.Extensions.Configuration;
99
using Microsoft.Extensions.Logging;
10+
using Serilog;
1011

1112
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
1213
{
@@ -31,6 +32,13 @@ public static IWebHost BuildWebHost(string[] args) =>
3132
});
3233
})
3334
.UseStartup<Startup>()
35+
.UseSerilog((builderContext, config) =>
36+
{
37+
config
38+
.MinimumLevel.Information()
39+
.Enrich.FromLogContext()
40+
.WriteTo.Console();
41+
})
3442
.Build();
3543
}
3644
}

src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.AspNetCore.Hosting;
88
using Microsoft.Extensions.Configuration;
99
using Microsoft.Extensions.Logging;
10+
using Serilog;
1011

1112
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
1213
{
@@ -31,6 +32,13 @@ public static IWebHost BuildWebHost(string[] args) =>
3132
});
3233
})
3334
.UseStartup<Startup>()
35+
.UseSerilog((builderContext, config) =>
36+
{
37+
config
38+
.MinimumLevel.Information()
39+
.Enrich.FromLogContext()
40+
.WriteTo.Console();
41+
})
3442
.Build();
3543
}
3644
}

src/ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" />
16+
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
17+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
1618
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
1719
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.1.0" />
1820
</ItemGroup>

src/Services/Basket/Basket.API/Basket.API.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" />
2222
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" />
2323
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.1.0" />
24+
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
25+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
2426
<PackageReference Include="StackExchange.Redis.StrongName" Version="1.2.4" />
2527
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
2628
</ItemGroup>

src/Services/Basket/Basket.API/Program.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.AspNetCore.Hosting;
55
using Microsoft.Extensions.Configuration;
66
using Microsoft.Extensions.Logging;
7+
using Serilog;
78
using System;
89
using System.IO;
910

@@ -49,6 +50,13 @@ public static IWebHost BuildWebHost(string[] args) =>
4950
builder.AddConsole();
5051
builder.AddDebug();
5152
})
53+
.UseSerilog((builderContext, config) =>
54+
{
55+
config
56+
.MinimumLevel.Information()
57+
.Enrich.FromLogContext()
58+
.WriteTo.Console();
59+
})
5260
.UseApplicationInsights()
5361
.Build();
5462
}

src/Services/Catalog/Catalog.API/Catalog.API.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.1.0" />
4343
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.1.0" />
4444
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" />
45+
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
46+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
4547
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
4648
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
4749
</ItemGroup>

src/Services/Catalog/Catalog.API/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.Extensions.DependencyInjection;
77
using Microsoft.Extensions.Logging;
88
using Microsoft.Extensions.Options;
9+
using Serilog;
910
using System;
1011
using System.IO;
1112
namespace Microsoft.eShopOnContainers.Services.Catalog.API
@@ -60,7 +61,14 @@ public static IWebHost BuildWebHost(string[] args) =>
6061
builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
6162
builder.AddConsole();
6263
builder.AddDebug();
63-
})
64+
})
65+
.UseSerilog((builderContext, config) =>
66+
{
67+
config
68+
.MinimumLevel.Information()
69+
.Enrich.FromLogContext()
70+
.WriteTo.Console();
71+
})
6472
.Build();
6573
}
6674
}

0 commit comments

Comments
 (0)