简体   繁体   English

Azure诊断,WADLogs,在Azure管理门户中查看

[英]Azure DIagnostics, WADLogs, Viewing in Azure Management Portal

This may be an extremely stupid question I am new to Azure. 我可能是Azure的新手,这可能是一个非常愚蠢的问题。

I am using Azure SDK 2.5 我正在使用Azure SDK 2.5

I have a worker role deployed to staging on Azure and I'm, using the diagnostics to trace the execution. 我已经部署了一个工作人员角色,以便在Azure上进行登台,并且正在使用诊断程序来跟踪执行情况。

Trace.TraceInformation("Service WorkerRole has stopped");

Is there a way to view the WadLogs file that can be viewed in the server explorer from the Azure management portal? 有没有办法查看可以从Azure管理门户在服务器资源管理器中查看的WadLogs文件? Or a way to have the data transferred to blob storage or somewhere else so it can be viewed online? 还是将数据传输到Blob存储或其他地方以便可以在线查看的方法?

Basically all I want to easily be able to view when my worker role throws and exception from the Azure management portal. 基本上,我希望能够轻松查看我的工作人员角色何时抛出以及来自Azure管理门户的异常。

You can use Application insights to monitor a worker role in the Azure portal. 您可以使用应用程序见解来监视Azure门户中的辅助角色。 Technically Microsoft is still adding support for console and other non-web apps, but I was able to make what is already there work for my purposes. 从技术上讲,Microsoft仍在增加对控制台和其他非Web应用程序的支持,但是我能够使已经存在的功能适用于我的目的。

I created an Application insight on the portal according to these instructions . 根据这些说明,我在门户上创建了Application Insight。

Then using the Nuget package manager in Visual Studio I added the Application insights API, Application insights for website (even though my worker role is not a web app) and the Application insights trace listener. 然后,使用Visual Studio中的Nuget程序包管理器,添加了应用程序见解API,网站的应用程序见解(即使我的工作人员角色不是Web应用程序)和应用程序见解跟踪侦听器。

I then created an Application insight instance by adding the following to the worker role. 然后,通过将以下内容添加到worker角色中,创建了一个Application Insight实例。

using Microsoft.ApplicationInsights;

namespace WorkerRole
{
public class WorkerRole : RoleEntryPoint
{
    private TelemetryClient tc = new TelemetryClient();

And then adding this to the onStart method in the worker role. 然后将其添加到工作角色中的onStart方法中。

        tc.Context.InstrumentationKey = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX";

You can find you instrumentation key in the Azure portal. 您可以在Azure门户中找到检测密钥。

After running or deploying my worker role I could then view all of my Trace.TraceInformation and TraceError statements in the Azure portal as well as add tc.TrackError and tc.TrackEvent statements to track errors, exceptions and events. 运行或部署辅助角色后,我可以在Azure门户中查看所有Trace.TraceInformation和TraceError语句,并添加tc.TrackError和tc.TrackEvent语句以跟踪错误,异常和事件。

You need to setup a storage account with your worker role to store the logs in a Table Storage. 您需要使用工作角色设置存储帐户,以将日志存储在表存储中。 Add the following code in your config file <ConfigurationSettings> <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="value="DefaultEndpointsProtocol=https;AccountName=<your storage account name here>;AccountKey=<your storage account key here>" /> </ConfigurationSettings> 将以下代码添加到配置文件<ConfigurationSettings> <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="value="DefaultEndpointsProtocol=https;AccountName=<your storage account name here>;AccountKey=<your storage account key here>" /> </ConfigurationSettings>

Your diagnostics related data will be stored in the azure tables and Trace logs are stored in the table name WadLogsTable . 与诊断相关的数据将存储在azure表中,而跟踪日志则存储在表名WadLogsTable中 You need to use a storage explorer to view the logs from the table. 您需要使用存储资源管理器来查看表中的日志。 I prefer to use Azure Storage Explorer as it is open source and supports Blobs,Tables and Queues. 我更喜欢使用Azure Storage Explorer,因为它是开源的,并且支持Blob,表和队列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM