Skip to content

Commit 23992ed

Browse files
authored
Merge pull request dotnet-architecture#952 from dotnet-architecture/features/add-seq-sink
Add Seq sink for Serilog and sample traces
2 parents 19f4478 + ec4fb3c commit 23992ed

111 files changed

Lines changed: 1829 additions & 807 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bld/
2626
# Visual Studio 2015 cache/options directory
2727
.vs/
2828

29-
# Files created by bundling and minification on startup
29+
# .js files created on build:
3030
src/Web/WebMVC/wwwroot/js/site*
3131

3232
# Uncomment if you have tasks that create the project's static files in wwwroot

docker-compose.override.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ version: '3.4'
77
# An external IP or DNS name has to be used (instead localhost and the 10.0.75.1 IP) when testing the Web apps and the Xamarin apps from remote machines/devices using the same WiFi, for instance.
88

99
services:
10+
seq:
11+
environment:
12+
- ACCEPT_EULA=Y
13+
ports:
14+
- "5340:80"
15+
1016
sql.data:
1117
environment:
1218
- SA_PASSWORD=Pass@word

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
version: '3.4'
22

33
services:
4+
seq:
5+
image: datalust/seq:latest
6+
47
sql.data:
58
image: microsoft/mssql-server-linux:2017-latest
69

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
5757

5858
if (!string.IsNullOrEmpty(pathBase))
5959
{
60-
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
60+
loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
6161
app.UsePathBase(pathBase);
6262
}
6363

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
5757
var pathBase = Configuration["PATH_BASE"];
5858
if (!string.IsNullOrEmpty(pathBase))
5959
{
60-
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
60+
loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
6161
app.UsePathBase(pathBase);
6262
}
6363

src/BuildingBlocks/EventBus/EventBusRabbitMQ/DefaultRabbitMQPersisterConnection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public bool TryConnect()
7272
.Or<BrokerUnreachableException>()
7373
.WaitAndRetry(_retryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) =>
7474
{
75-
_logger.LogWarning(ex.ToString());
75+
_logger.LogWarning(ex, "RabbitMQ Client could not connect after {TimeOut}s ({ExceptionMessage})", $"{time.TotalSeconds:n1}", ex.Message);
7676
}
7777
);
7878

@@ -88,7 +88,7 @@ public bool TryConnect()
8888
_connection.CallbackException += OnCallbackException;
8989
_connection.ConnectionBlocked += OnConnectionBlocked;
9090

91-
_logger.LogInformation($"RabbitMQ persistent connection acquired a connection {_connection.Endpoint.HostName} and is subscribed to failure events");
91+
_logger.LogInformation("RabbitMQ Client acquired a persistent connection to '{HostName}' and is subscribed to failure events", _connection.Endpoint.HostName);
9292

9393
return true;
9494
}

src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void Publish(IntegrationEvent @event)
7676
.Or<SocketException>()
7777
.WaitAndRetry(_retryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) =>
7878
{
79-
_logger.LogWarning(ex.ToString());
79+
_logger.LogWarning(ex, "Could not publish event: {EventId} after {Timeout}s ({ExceptionMessage})", @event.Id, $"{time.TotalSeconds:n1}", ex.Message);
8080
});
8181

8282
using (var channel = _persistentConnection.CreateModel())

src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void Subscribe<T, TH>()
8383
}
8484
catch (ServiceBusException)
8585
{
86-
_logger.LogInformation($"The messaging entity {eventName} already exists.");
86+
_logger.LogWarning("The messaging entity {eventName} already exists.", eventName);
8787
}
8888
}
8989

@@ -105,7 +105,7 @@ public void Unsubscribe<T, TH>()
105105
}
106106
catch (MessagingEntityNotFoundException)
107107
{
108-
_logger.LogInformation($"The messaging entity {eventName} Could not be found.");
108+
_logger.LogWarning("The messaging entity {eventName} Could not be found.", eventName);
109109
}
110110

111111
_subsManager.RemoveSubscription<T, TH>();
@@ -194,7 +194,7 @@ private void RemoveDefaultRule()
194194
}
195195
catch (MessagingEntityNotFoundException)
196196
{
197-
_logger.LogInformation($"The messaging entity { RuleDescription.DefaultRuleName } Could not be found.");
197+
_logger.LogWarning("The messaging entity {DefaultRuleName} Could not be found.", RuleDescription.DefaultRuleName);
198198
}
199199
}
200200
}

src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHostExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static IWebHost MigrateDbContext<TContext>(this IWebHost webHost, Action<
3232

3333
try
3434
{
35-
logger.LogInformation($"Migrating database associated with context {typeof(TContext).Name}");
35+
logger.LogInformation("Migrating database associated with context {DbContextName}", typeof(TContext).Name);
3636

3737
if (underK8s)
3838
{
@@ -55,11 +55,11 @@ public static IWebHost MigrateDbContext<TContext>(this IWebHost webHost, Action<
5555
retry.Execute(() => InvokeSeeder(seeder, context, services));
5656
}
5757

58-
logger.LogInformation($"Migrated database associated with context {typeof(TContext).Name}");
58+
logger.LogInformation("Migrated database associated with context {DbContextName}", typeof(TContext).Name);
5959
}
6060
catch (Exception ex)
6161
{
62-
logger.LogError(ex, $"An error occurred while migrating the database used on context {typeof(TContext).Name}");
62+
logger.LogError(ex, "An error occurred while migrating the database used on context {DbContextName}", typeof(TContext).Name);
6363
if (underK8s)
6464
{
6565
throw; // Rethrow under k8s because we rely on k8s to re-run the pod

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,28 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.2" />
17-
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="2.2.0" />
1816
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="2.2.0" />
1917
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="2.2.0" />
18+
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="2.2.0" />
19+
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.2" />
20+
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" />
2021
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
2122
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
2223
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.2" />
2324
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.2.2" />
25+
<PackageReference Include="Microsoft.AspNetCore.App" />
2426
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
27+
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
28+
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.1.0" />
2529
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
26-
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
27-
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" />
28-
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />
29-
<PackageReference Include="StackExchange.Redis.StrongName" Version="1.2.6" />
3030
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />
3131
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
32+
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.2" />
33+
<PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" />
3234
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
35+
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
36+
<PackageReference Include="StackExchange.Redis.StrongName" Version="1.2.6" />
3337
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
34-
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
3538
</ItemGroup>
3639

3740
<ItemGroup>

0 commit comments

Comments
 (0)