feat: log to seq
This commit is contained in:
parent
d221441c10
commit
ca99bdfb94
3 changed files with 11 additions and 0 deletions
|
|
@ -32,6 +32,7 @@
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
|
<PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
|
||||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Seq" Version="8.0.0" />
|
||||||
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
|
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.1" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ public class Config
|
||||||
|
|
||||||
public int MetricsPort { get; init; } = 5001;
|
public int MetricsPort { get; init; } = 5001;
|
||||||
public bool EnableMetrics { get; init; } = true;
|
public bool EnableMetrics { get; init; } = true;
|
||||||
|
|
||||||
|
public string? SeqLogUrl { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DatabaseConfig
|
public class DatabaseConfig
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,14 @@ public static class StartupExtensions
|
||||||
// The default theme doesn't support light mode
|
// The default theme doesn't support light mode
|
||||||
.WriteTo.Console(theme: AnsiConsoleTheme.Sixteen);
|
.WriteTo.Console(theme: AnsiConsoleTheme.Sixteen);
|
||||||
|
|
||||||
|
if (config.Logging.SeqLogUrl != null)
|
||||||
|
{
|
||||||
|
logCfg.WriteTo.Seq(
|
||||||
|
config.Logging.SeqLogUrl,
|
||||||
|
restrictedToMinimumLevel: LogEventLevel.Verbose
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// AddSerilog doesn't seem to add an ILogger to the service collection, so add that manually.
|
// AddSerilog doesn't seem to add an ILogger to the service collection, so add that manually.
|
||||||
builder.Services.AddSerilog().AddSingleton(Log.Logger = logCfg.CreateLogger());
|
builder.Services.AddSerilog().AddSingleton(Log.Logger = logCfg.CreateLogger());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue