简体   繁体   中英

Azure DIagnostics, WADLogs, Viewing in Azure Management Portal

This may be an extremely stupid question I am new to Azure.

I am using Azure SDK 2.5

I have a worker role deployed to staging on Azure and I'm, using the diagnostics to trace the execution.

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? Or a way to have the data transferred to blob storage or somewhere else so it can be viewed online?

Basically all I want to easily be able to view when my worker role throws and exception from the Azure management portal.

You can use Application insights to monitor a worker role in the Azure portal. 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.

I created an Application insight on the portal according to these instructions .

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.

I then created an Application insight instance by adding the following to the worker role.

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.

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

You can find you instrumentation key in the Azure portal.

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.

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>

Your diagnostics related data will be stored in the azure tables and Trace logs are stored in the table name 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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