mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-02-16 10:58:32 -05:00
Tweak logging
This commit is contained in:
@@ -49,7 +49,7 @@ public class PowerReader(IConfiguration configuration, Database database, ILogge
|
|||||||
|
|
||||||
var content = response.Content!;
|
var content = response.Content!;
|
||||||
|
|
||||||
logger.LogInformation("API response: {content}", content);
|
logger.LogDebug("API response: {content}", content);
|
||||||
|
|
||||||
var sample = JsonSerializer.Deserialize<PowerSample>(content);
|
var sample = JsonSerializer.Deserialize<PowerSample>(content);
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ public class PowerReader(IConfiguration configuration, Database database, ILogge
|
|||||||
|
|
||||||
var json = JsonSerializer.Serialize(status);
|
var json = JsonSerializer.Serialize(status);
|
||||||
|
|
||||||
logger.LogInformation("Output message: {json}", json);
|
logger.LogDebug("Output message: {json}", json);
|
||||||
|
|
||||||
if (_hubConnection == null)
|
if (_hubConnection == null)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ public static class Program
|
|||||||
|
|
||||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
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
|
openTelemetry.WithMetrics(meterProviderBuilder => meterProviderBuilder
|
||||||
.AddAspNetCoreInstrumentation()
|
.AddAspNetCoreInstrumentation()
|
||||||
@@ -57,9 +57,6 @@ public static class Program
|
|||||||
|
|
||||||
tracerProviderBuilder.AddSource(nameof(PowerReader));
|
tracerProviderBuilder.AddSource(nameof(PowerReader));
|
||||||
|
|
||||||
if (builder.Environment.IsDevelopment())
|
|
||||||
tracerProviderBuilder.AddConsoleExporter();
|
|
||||||
|
|
||||||
tracerProviderBuilder.SetErrorStatusOnException();
|
tracerProviderBuilder.SetErrorStatusOnException();
|
||||||
|
|
||||||
tracerProviderBuilder.AddOtlpExporter(exporterOptions =>
|
tracerProviderBuilder.AddOtlpExporter(exporterOptions =>
|
||||||
@@ -69,14 +66,11 @@ public static class Program
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddLogging((loggingBuilder) =>
|
builder.Services.AddLogging(loggingBuilder =>
|
||||||
{
|
{
|
||||||
loggingBuilder.SetMinimumLevel(LogLevel.Information);
|
loggingBuilder.SetMinimumLevel(LogLevel.Information);
|
||||||
loggingBuilder.AddOpenTelemetry(options =>
|
loggingBuilder.AddOpenTelemetry(options =>
|
||||||
{
|
{
|
||||||
if (builder.Environment.IsDevelopment())
|
|
||||||
options.AddConsoleExporter();
|
|
||||||
|
|
||||||
options.AddOtlpExporter(exporterOptions =>
|
options.AddOtlpExporter(exporterOptions =>
|
||||||
{
|
{
|
||||||
exporterOptions.Endpoint = new Uri(builder.Configuration["Telemetry:Endpoint"]!);
|
exporterOptions.Endpoint = new Uri(builder.Configuration["Telemetry:Endpoint"]!);
|
||||||
|
|||||||
8
Power/Service/appsettings.Development.json
Normal file
8
Power/Service/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Debug",
|
||||||
|
"Microsoft": "Information"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information"
|
"Default": "Warning",
|
||||||
|
"Microsoft": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Power": {
|
"Power": {
|
||||||
|
|||||||
Reference in New Issue
Block a user