feat: Read Seq logging config from appsettings.json + add Console logging
This commit is contained in:
@@ -15,8 +15,13 @@ using Hangfire.SqlServer;
|
|||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
var levelSwitch = new LoggingLevelSwitch();
|
var levelSwitch = new LoggingLevelSwitch();
|
||||||
|
|
||||||
|
// Read Seq configuration from appsettings.json
|
||||||
|
var seqServerUrl = builder.Configuration["Seq:ServerUrl"] ?? "http://seq-svc:5341";
|
||||||
|
var seqApiKey = builder.Configuration["Seq:ApiKey"];
|
||||||
|
|
||||||
var logger = new LoggerConfiguration()
|
var logger = new LoggerConfiguration()
|
||||||
//.WriteTo.Console()
|
.WriteTo.Console()
|
||||||
//.WriteTo.MSSqlServer(builder.Configuration.GetConnectionString("LogConnection"),
|
//.WriteTo.MSSqlServer(builder.Configuration.GetConnectionString("LogConnection"),
|
||||||
// sinkOptions: new MSSqlServerSinkOptions
|
// sinkOptions: new MSSqlServerSinkOptions
|
||||||
// {
|
// {
|
||||||
@@ -24,8 +29,8 @@ var logger = new LoggerConfiguration()
|
|||||||
// SchemaName = "Log",
|
// SchemaName = "Log",
|
||||||
// AutoCreateSqlTable = true
|
// AutoCreateSqlTable = true
|
||||||
// })
|
// })
|
||||||
.WriteTo.Seq("https://seq.afrino.co",
|
.WriteTo.Seq(seqServerUrl,
|
||||||
apiKey: "oxpvpUzU1pZxMS4s3Fqq",
|
apiKey: string.IsNullOrEmpty(seqApiKey) ? null : seqApiKey,
|
||||||
controlLevelSwitch: levelSwitch)
|
controlLevelSwitch: levelSwitch)
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
builder.Logging.AddSerilog(logger);
|
builder.Logging.AddSerilog(logger);
|
||||||
|
|||||||
@@ -53,5 +53,9 @@
|
|||||||
"Authentication": {
|
"Authentication": {
|
||||||
"Authority": "https://ids.domain.com/",
|
"Authority": "https://ids.domain.com/",
|
||||||
"Audience": "domain_api"
|
"Audience": "domain_api"
|
||||||
|
},
|
||||||
|
"Seq": {
|
||||||
|
"ServerUrl": "http://seq-svc:5341",
|
||||||
|
"ApiKey": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user