Skip to content

I don't really get the logging best practices #2837

Open
@AndiRudi

Description

@AndiRudi

Type of issue

Missing information

Description

We have created a .net aspire based application with a couple services and deployed it to Azure. We have not yet added anything else in regards to logging and monitoring. I guess this is the default for a lot of people.

Our next step was to get information about issues sent via Email. That basically means we want to get all log messages which are errors and warnings via email. So I was looking how to set this up.

I do know a bit about Azure, but I am not really into all of the logging and monitoring tools so I watched about Log Analytics, Application Insights and Azure Monitor to find the simplest solution to get that task done. I also read this article https://learn.microsoft.com/en-us/dotnet/aspire/deployment/azure/application-insights but I am still confused

The article is about Azure Monitor but then talks about setting up Application Insights. This confused me, because it seems that Azure Monitor is only needed on top of Insights and Log Analytics so not really a necessity when starting. In the end I don't know what I should set up now.

My guess is, that Log Analytics is working per default when you deploy an aspire application and Application Insights and Azure Monitor are not needed. So I was looking into setting up some alerts regarding the logs in Log Analytics. But then I found out that the log messages there are capture from the console and are multiple lines like in this example:

warn: SomeClass.SomeClass.Worker[0]
Due to no activity backing off and setting the delay to 5

This means that when I setup an alert regarding "warn" it would probably sent only the first line, but not the second. So it seems that the default way how logging is captured is kinda wrong.

In the end I would like an article that explains all of that. First starts to explain how Azure Monitor, Application Insights and Log Analytics work together and what is needed to start with and what is maybe needed later. Then it would be good to explain how to setup logging the right way. Should we do it with the console logging or or is this not a good practice and we should ditch it directly and stream logs to Application Insights.

And above all, we always need structured logging of course. So all solutions that cannot deal with that are kinda useless and should be ditched directly.

I am not sure if this helps. But I wrote it anyway. Thanks

Page URL

https://learn.microsoft.com/en-us/dotnet/aspire/deployment/azure/application-insights

Content source URL

https://github.com/dotnet/docs-aspire/blob/main/docs/deployment/azure/application-insights.md

Document Version Independent Id

fee898a4-8244-7139-151f-38f7c49e9f45

Platform Id

b06aa768-9adf-7cf4-4c3c-7ac02fb92334

Article author

@IEvangelist

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions