-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move structured logging into aspire (#1745)
* move structured logging into aspire * don't write output outside of test host
- Loading branch information
1 parent
9d70b0b
commit 68ef1f8
Showing
35 changed files
with
156 additions
and
336 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,45 +1,12 @@ | ||
using System; | ||
using Api; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.Hosting; | ||
using Serilog; | ||
using Serilog.Events; | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
Console.Title = "Api"; | ||
builder.AddServiceDefaults(); | ||
|
||
Log.Logger = new LoggerConfiguration() | ||
.WriteTo.Console() | ||
.CreateBootstrapLogger(); | ||
var app = builder | ||
.ConfigureServices() | ||
.ConfigurePipeline(); | ||
|
||
Log.Information("Starting up"); | ||
|
||
try | ||
{ | ||
var builder = WebApplication.CreateBuilder(args); | ||
builder.AddServiceDefaults(); | ||
|
||
builder.Host.UseSerilog((ctx, lc) => lc | ||
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}") | ||
.Enrich.FromLogContext() | ||
.MinimumLevel.Debug() | ||
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) | ||
.MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Information) | ||
.MinimumLevel.Override("System", LogEventLevel.Warning) | ||
.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information) | ||
.ReadFrom.Configuration(ctx.Configuration)); | ||
|
||
var app = builder | ||
.ConfigureServices() | ||
.ConfigurePipeline(); | ||
|
||
app.Run(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log.Fatal(ex, "Unhandled exception"); | ||
} | ||
finally | ||
{ | ||
Log.Information("Shut down complete"); | ||
Log.CloseAndFlush(); | ||
} | ||
app.Run(); |
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
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
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
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
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
Oops, something went wrong.