diff --git a/Power/Service/PowerReader.cs b/Power/Service/PowerReader.cs index e568705..0adbcd4 100644 --- a/Power/Service/PowerReader.cs +++ b/Power/Service/PowerReader.cs @@ -49,7 +49,7 @@ public class PowerReader(IConfiguration configuration, Database database, ILogge var content = response.Content!; - logger.LogInformation("API response: {content}", content); + logger.LogDebug("API response: {content}", content); var sample = JsonSerializer.Deserialize(content); @@ -65,7 +65,7 @@ public class PowerReader(IConfiguration configuration, Database database, ILogge var json = JsonSerializer.Serialize(status); - logger.LogInformation("Output message: {json}", json); + logger.LogDebug("Output message: {json}", json); if (_hubConnection == null) return; diff --git a/Power/Service/Program.cs b/Power/Service/Program.cs index d426e41..1d0b24d 100644 --- a/Power/Service/Program.cs +++ b/Power/Service/Program.cs @@ -32,9 +32,9 @@ public static class Program AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); - var name = Assembly.GetExecutingAssembly().GetName().Name; + var serviceName = Assembly.GetExecutingAssembly().GetName().Name; - openTelemetry.ConfigureResource(resource => resource.AddService(name!)); + openTelemetry.ConfigureResource(resource => resource.AddService(serviceName!)); openTelemetry.WithMetrics(meterProviderBuilder => meterProviderBuilder .AddAspNetCoreInstrumentation() @@ -57,9 +57,6 @@ public static class Program tracerProviderBuilder.AddSource(nameof(PowerReader)); - if (builder.Environment.IsDevelopment()) - tracerProviderBuilder.AddConsoleExporter(); - tracerProviderBuilder.SetErrorStatusOnException(); tracerProviderBuilder.AddOtlpExporter(exporterOptions => @@ -69,14 +66,11 @@ public static class Program }); }); - builder.Services.AddLogging((loggingBuilder) => + builder.Services.AddLogging(loggingBuilder => { loggingBuilder.SetMinimumLevel(LogLevel.Information); loggingBuilder.AddOpenTelemetry(options => { - if (builder.Environment.IsDevelopment()) - options.AddConsoleExporter(); - options.AddOtlpExporter(exporterOptions => { exporterOptions.Endpoint = new Uri(builder.Configuration["Telemetry:Endpoint"]!); diff --git a/Power/Service/appsettings.Development.json b/Power/Service/appsettings.Development.json new file mode 100644 index 0000000..a9a0d0f --- /dev/null +++ b/Power/Service/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "Microsoft": "Information" + } + } +} \ No newline at end of file diff --git a/Power/Service/appsettings.json b/Power/Service/appsettings.json index 7a331a4..cc8efcd 100644 --- a/Power/Service/appsettings.json +++ b/Power/Service/appsettings.json @@ -1,7 +1,8 @@ { "Logging": { "LogLevel": { - "Default": "Information" + "Default": "Warning", + "Microsoft": "Information" } }, "Power": {