I have som problem with application logs in cloudwatch.
I'am using dotnet core and Elastic container services and have setup cloudwatch as application logs, but the logs only outputs the startup like this:
But when I run the application local the application logs are more detailed and show exceptions being thrown like this:
I use serilog and set it up like this:
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);
[...]
}
And my appsettings.json (I have tried a lot of different combinations in this file):
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
This is a lot. But if anyone could point me in the right direction I would be happy. Any tutorial or tips on how to setup detailed application logs with cloudwatch and aspnet core would be appreciated :)