Reputation: 11
We are using Serilog but have recently added Elastic APM as we will be logging to Kibana. But with the addition of Elastic APM we can no longer view logs with log level debug. This goes for the local txt log file, the console and Kibana. The application is written in .Net 8. I have configured the log level to debug at every possible step I could find, but nothing works.
We are using the latest setup per the documentation, but have also tried the deprecated version with no luck.
appsettings.json
"Serilog": {
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.File",
"Serilog.Enrichers.CorrelationId"
],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"System": "Warning",
"Elastic.Apm": "Debug"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"restrictedToMinimumLevel": "Debug"
}
},
{
"Name": "File",
"Args": {
"path": "Logs/Application.log",
"restrictedToMinimumLevel": "Debug"
}
}
],
...
"ElasticApm": {
"CloudProvider": "none",
"VerifyServerCert": false,
"CaptureBody": "all",
"Instrument": "true",
"ErrorOnAbortedRequests": "true",
"ServiceName": "ApplicationName",
"DisableMetrics": "system.cpu.total.norm.pct, system.process.cpu.total.norm.pct",
"LogLevel": "Debug"
},
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Warning",
"Elastic.Apm": "Debug"
}
}
We are then using the following configuration for the logger.
var loggerConfiguration = new LoggerConfiguration()
.Enrich.FromLogContext()
.Enrich.WithProperty("Environment", environment.EnvironmentName)
.Enrich.WithProperty("Application", configuration["ElasticApm:ServiceName"])
.MinimumLevel.Debug()
.WriteTo.Console()
.WriteTo.Elasticsearch(new[] { new Uri(configuration["Elastic:Url"]!) }, options =>
{
options.DataStream = new DataStreamName(
"logs",
configuration["ElasticApm:ServiceName"]!,
environment.EnvironmentName.ToLower());
}, transport =>
{
transport.Authentication(new ApiKey(configuration["Elastic:ApiKey"]!));
transport.ServerCertificateValidationCallback((o, certificate, chain, errors) => true);
});
As you can see, we have the debug level set at multiple places, and per the documentation it should be enough to only set it in either "Logging:LogLevel:Default", "Logging:LogLevel:Elastic.Apm" or "ElasticApm:LogLevel". But since neither of these actually show the result, I have tried in further places. I could not find any information as to solve this and hope I can find some assistance in this forum. Any help is greatly appreciated, please let me know if any further information is needed. Thank you.
Upvotes: 1
Views: 25