我是编程新手,我正在尝试为 .net 核心项目实现日志记录解决方案。
我想收集默认和 Microsoft 类别日志。
APPSETTING.JSON
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"System": "Warning",
"Microsoft": "Information"
},
"File": {
"location": "logs/timeapi.log"
}
},
"EnableSwagger": true
}
Run Code Online (Sandbox Code Playgroud)
程序.CS
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseSerilogRequestLogging();
Run Code Online (Sandbox Code Playgroud)
启动文件
app.UseSerilogRequestLogging(options =>
options.RequestProjection =
r => new { r.IsHttps, QueryString = r.QueryString.Value });
app.UseMvc();
Run Code Online (Sandbox Code Playgroud)
https://github.com/mthamil/AspNetCore.Serilog.RequestLoggingMiddleware
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
Unable to resolve service for type 'Serilog.ILogger' while attempting to activate 'AspNetCore.Serilog.RequestLoggingMiddleware.SerilogRequestMiddleware'.
Run Code Online (Sandbox Code Playgroud) 我将在此处粘贴用于AWS Elastic Loadbalancer的Terraform脚本
resource "aws_elb" "elb" {
name = "${var.elb_name}"
subnets = ["${var.subnet_ids}"]
internal = "${var.elb_is_internal}"
security_groups = ["${var.elb_security_group}"]
listener {
instance_port = "${var.backend_port}"
instance_protocol = "${var.backend_protocol}"
lb_port = 80
lb_protocol = "http"
}
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
target = "${var.health_check_target}"
interval = 30
}
cross_zone_load_balancing = true
}
Run Code Online (Sandbox Code Playgroud)
你们可以帮助我使用terraform变量创建多个侦听器吗?