I've recently connected Application Insights to my Azure functions application. I write logs using a pattern suggested by Microsoft documentation:
public MyClass {
private readonly ILogger _logger;
public MyClass(ILogger<MyClass> logger){
_logger = logger;
}
public void MyMethod {
_loger.LogWarning("Test message");
}
}
What I do not understand is how to find the test message in Application insights opened in Portal. I'd like to know how to search for messages from "MyClass" with particular error level. Screenshots will be appreciated! Thank you in advance for some help in this newbie question.
When using the portal you can visually query the logs using the transaction search. Logs written using an ILogger
implementation usually ends up in the traces table. In the azure portal you can define filters for the Trace Severity Level and CategoryName like shown below. The CategoryName filter in your case should be set to the value <full namespace>.MyClass
and the Trace Severity Level should be Warning
Or you can write this query
traces
| where customDimensions.CategoryName == "Full.Namespace.MyClass"
| where severityLevel == 2
using the Logs as shown here: