Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUERY] Using Azure Monitor OpenTelemetry alongside Serilog #48678

Open
SamueleFurnari opened this issue Mar 10, 2025 · 1 comment
Open

[QUERY] Using Azure Monitor OpenTelemetry alongside Serilog #48678

SamueleFurnari opened this issue Mar 10, 2025 · 1 comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Distro Monitor OpenTelemetry Distro needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@SamueleFurnari
Copy link

SamueleFurnari commented Mar 10, 2025

Library name and version

Azure.Monitor.OpenTelemetry.AspNetCore 1.2.0

Query/Question

In a project I configured Azure Monitor OpenTelemetry to make monitoring easy. At the same time I would like to use the flexibility of serilog to write formatted logs to console and file.

In the project I also use entity framework. If I disable Serilog, on app insight I also find the queries towards the database logged. If I enable Serilog, I no longer see the traces.

On stack overflow I found this question, but by configuring serilog as indicated, I see the traces on app insights but I still do not see the sql entity framework queries.

Do you have any suggestion?

Thanks!!

Following there is the cose I used and the content of app.settings

var resourceAttributes = new Dictionary<string, object>
{
    { "service.name", serviceName },
    { "service.namespace", "my-namespace" },
    { "service.instance.id", "my-instance" }
};

builder.Logging.ClearProviders();

builder.Services
    .AddOpenTelemetry()
    .UseAzureMonitor()
    .ConfigureResource(resourceBuilder => resourceBuilder.AddAttributes(resourceAttributes));

builder.Services.AddSerilog(
    (services, lc) => lc
        .ReadFrom.Configuration(builder.Configuration)
        .ReadFrom.Services(services)
        .Enrich.FromLogContext(), writeToProviders: true);

"Serilog": {
  "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
  "WriteTo": [
    { "Name": "Console" },
    {
      "Name": "File",
      "Args": {
        "path": "/logs/log-.txt",
        "rollingInterval": "Day",
        "rollOnFileSizeLimit": true,
        "formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact"
      }
    }
  ],
  "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
}

Environment

No response

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Mar 10, 2025
@jsquire jsquire added Service Attention Workflow: This issue is responsible by Azure service team. Client This issue points to a problem in the data-plane of the library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Monitor - Distro Monitor OpenTelemetry Distro and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Mar 10, 2025
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @rajkumar-rangaraj @TimothyMothra.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Distro Monitor OpenTelemetry Distro needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

2 participants