我有一个简单的控制台应用程序来跟踪跟踪。但是,它不会在 Azure Web 门户的应用程序见解中记录跟踪消息。我错过了什么?
我查看了 https://learn.microsoft.com/en-us/azure/application-insights/application-insights-console来自 docs.ms.com,但在那里找不到答案。
class Program
{
static void Main(string[] args)
{
TelemetryConfiguration.Active.InstrumentationKey = "<KEY_HERE>";
var telemetryClient = new TelemetryClient();
// Get the object used to communicate with the FTP server
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(Properties.Settings.Default.FtpEndpoint);
// FTP credentials
request.Credentials = new NetworkCredential(Properties.Settings.Default.FtpUserName, Properties.Settings.Default.FtpPassword);
// FTP request method
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
{
telemetryClient.TrackTrace("Successfully retrieved a list of FTP directories");
telemetryClient.Flush();
Console.WriteLine(reader.ReadToEnd());
}
}
}
最佳答案
需要将TelemetryConfiguration
对象放入TelemetryClient()
中。
请确保已分配右键。
关于c# - 我在 Application Insights 中看不到我的轨迹跟踪消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48485084/