How to Integrate .net core application to see logs in Azure Kubernates Cluster container insights

Hemanth Kumar Reddy Rachala 0 Reputation points

How can we integrate to see logs of our .net core API application in deployed Azure kubernates cluster container insights. what are all the code changes to be done to see errors and exceptions in container insights.

I got to know that WriteTo.Console() , console logs will be directly captured in runtime by kubernates cluster. So, what changes need to be done in .net core API application. Please respond ASAP.

A set of technologies in the .NET Framework for building web applications and XML web services.
4,241 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,894 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anveshreddy Nimmala 2,790 Reputation points Microsoft Vendor

    Hello Hemanth Kumar Reddy Rachala,Welcome to microsoft Q&A, thankyou for posting your query here.

    Serilog logging for ASP.NET Core. This package routes ASP.NET Core log messages through Serilog, so you can get information about ASP.NET's internal operations written to the same Serilog sinks as your application events.

    With Serilog.AspNetCore installed and configured, you can write log messages directly through Serilog or any ILogger interface injected by ASP.NET. All loggers will use the same underlying implementation, levels, and destinations.

    install the Serilog.AspNetCore and Serilog console NuGet packages into your app.

    dotnet add package Serilog.AspNetCore

    dotnet add package Serilog.Sinks.Console

    follow this links to configure

    Enable Azure Monitor for Containers for your AKS cluster.

    When you deploy your .NET Core API application to AKS, the logs written to the console by Serilog will be captured automatically by Azure Monitor for Containers.

    You can use this query under AKS -insights -logs to view your application logs.


    | where LogEntry contains "ERROR"

    Hope this helps you.

    If an answer has been helpful, please consider accepting the answer to help increase visibility of this question for other members of the Microsoft Q&A community. If not, please let us know what is still needed in the comments so the question can be answered. Thank you for helping to improve Microsoft Q&A!

    0 comments No comments