Skip to content

Commit

Permalink
Returned standard opentelemetry logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Feb 21, 2024
1 parent 1819ef4 commit fb4f339
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/BUTR.Site.NexusMods.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

using Npgsql;

using OpenTelemetry.Exporter;
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.ResourceDetectors.Container;
using OpenTelemetry.Resources;
Expand Down Expand Up @@ -164,5 +166,26 @@ public static IHostBuilder CreateHostBuilder(string[] args) => Host
configuration
.ReadFrom.Configuration(context.Configuration)
.ReadFrom.Services(services);
}, writeToProviders: true)
.ConfigureLogging((ctx, builder) =>
{
var oltpSection = ctx.Configuration.GetSection("Oltp");
if (oltpSection == null!) return;
var loggingEndpoint = oltpSection.GetValue<string>("LoggingEndpoint");
if (loggingEndpoint is null) return;
var loggingProtocol = oltpSection.GetValue<OtlpExportProtocol>("LoggingProtocol");
builder.AddOpenTelemetry(o =>
{
o.IncludeScopes = true;
o.ParseStateValues = true;
o.IncludeFormattedMessage = true;
o.AddOtlpExporter((options, processorOptions) =>
{
options.Endpoint = new Uri(loggingEndpoint);
options.Protocol = loggingProtocol;
});
});
});
}

0 comments on commit fb4f339

Please sign in to comment.