asp.net-core - 从 aspnet 核心应用程序到 cloudwatch 的详细应用程序日志
问题描述
我对 cloudwatch 中的应用程序日志有一些问题。
我正在使用 dotnet core 和 Elastic 容器服务,并将 cloudwatch 设置为应用程序日志,但日志仅输出如下启动:
但是当我在本地运行应用程序时,应用程序日志更详细,并显示抛出如下异常:
我使用 serilog 并像这样设置它:
private void ConfigureSeriLog()
{
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(Configuration)
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Information()
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateLogger();
}
public void ConfigureServices(IServiceCollection services)
{
[...]
services.AddLogging(loggingBuilder =>
loggingBuilder.AddSerilog(dispose: true));
[...]
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
ILoggerFactory loggerFactory,
IApplicationLifetime appLifetime)
{
[...]
loggerFactory.AddSerilog();
appLifetime.ApplicationStopped.Register(Log.CloseAndFlush);
[...]
}
还有我的 appsettings.json(我在这个文件中尝试了很多不同的组合):
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
这是很多。但如果有人能指出我正确的方向,我会很高兴。任何有关如何使用 cloudwatch 和 aspnet 核心设置详细应用程序日志的教程或提示将不胜感激:)
解决方案
我不是该主题的专家,但我认为您需要在 loggerConfiguration 中添加 .WriteTo.AmazonCloudWatch(options, client)。
推荐阅读
- .net - 如何获取 Amazon Redshift 集群中的所有数据库名称
- github - 我的家庭连接根本无法访问 Github
- reactjs - ReactJS 中的 componentWillMount 和 UNSAFE_componentWillMount 有什么区别
- javascript - “响应”不是有效的脚本名称,名称必须以 .js 结尾 - Microsoft 教程
- php - 如何在没有数据库的情况下验证令牌?
- sql - 如何使用单个 where 语句为条件选择多个列?
- indexeddb - 浏览器本地存储是否与 indexeddb 共享空间,
- python - 尽管形状相同,但 Python 形状未对齐
- c++ - 针对 std::function 的 lambda 表达式和模板推导:为什么会这样?
- reporting-services - SSRS 报表渲染相关