我没有在Application Insights中看到我的跟踪跟踪消息

时间:2018-01-28 09:55:37

标签: c# azure azure-application-insights

我有一个跟踪跟踪的简单控制台应用程序。但是,它不会在Azure Web门户的应用程序洞察中记录跟踪消息。我错过了什么?

我查看了docs.ms.com上的https://docs.microsoft.com/en-us/azure/application-insights/application-insights-console,但在那里找不到答案。

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());
        }
    }
}

0 个答案:

没有答案