feat: switching to logging via OpenTelemetry
This commit is contained in:
@@ -8,7 +8,7 @@ using Serilog.Context;
|
||||
using Serilog.Events;
|
||||
using Serilog.Filters;
|
||||
using Serilog.Formatting.Compact;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
@@ -46,9 +46,18 @@ public static class LoggerConfiguration
|
||||
rollingInterval: RollingInterval.Day);
|
||||
}
|
||||
|
||||
if (generalConfig != null && !string.IsNullOrEmpty(generalConfig.ApiServerSeq) &&
|
||||
Uri.TryCreate(generalConfig.ApiServerSeq, UriKind.Absolute, out var _))
|
||||
configuration.WriteTo.Seq(generalConfig.ApiServerSeq, apiKey: generalConfig.ApiKeySeq);
|
||||
if (!string.IsNullOrEmpty(generalConfig?.OpenTelemetryEndpoint)
|
||||
&& !string.IsNullOrEmpty(generalConfig.OpenTelemetryServiceName))
|
||||
configuration.WriteTo.OpenTelemetry(options =>
|
||||
{
|
||||
options.Endpoint = generalConfig.OpenTelemetryEndpoint;
|
||||
options.Protocol = Serilog.Sinks.OpenTelemetry.OtlpProtocol.Grpc;
|
||||
options.ResourceAttributes = new Dictionary<string, object>
|
||||
{
|
||||
["service.name"] = generalConfig.OpenTelemetryServiceName,
|
||||
["deployment.environment"] = context.HostingEnvironment.EnvironmentName
|
||||
};
|
||||
});
|
||||
|
||||
configuration
|
||||
.MinimumLevel.Override("Microsoft.AspNetCore.Hosting", LogEventLevel.Warning)
|
||||
|
Reference in New Issue
Block a user