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 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()
|
||||
//.WriteTo.Console()
|
||||
.WriteTo.Console()
|
||||
//.WriteTo.MSSqlServer(builder.Configuration.GetConnectionString("LogConnection"),
|
||||
// sinkOptions: new MSSqlServerSinkOptions
|
||||
// {
|
||||
@@ -24,8 +29,8 @@ var logger = new LoggerConfiguration()
|
||||
// SchemaName = "Log",
|
||||
// AutoCreateSqlTable = true
|
||||
// })
|
||||
.WriteTo.Seq("https://seq.afrino.co",
|
||||
apiKey: "oxpvpUzU1pZxMS4s3Fqq",
|
||||
.WriteTo.Seq(seqServerUrl,
|
||||
apiKey: string.IsNullOrEmpty(seqApiKey) ? null : seqApiKey,
|
||||
controlLevelSwitch: levelSwitch)
|
||||
.CreateLogger();
|
||||
builder.Logging.AddSerilog(logger);
|
||||
|
||||
@@ -53,5 +53,9 @@
|
||||
"Authentication": {
|
||||
"Authority": "https://ids.domain.com/",
|
||||
"Audience": "domain_api"
|
||||
},
|
||||
"Seq": {
|
||||
"ServerUrl": "http://seq-svc:5341",
|
||||
"ApiKey": ""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user