Windows Azure Trace Log not working

人盡茶涼 提交于 2019-12-03 06:02:30

I had this same problem. I was using the solution here. I believe the piece you are missing is the location where logs are scheduled to be transferred (in this case, using a LocalResource path):

public override bool OnStart()
{
    Trace.WriteLine("Entering OnStart...");

    var traceResource = RoleEnvironment.GetLocalResource("TraceFiles");
    var config = DiagnosticMonitor.GetDefaultInitialConfiguration();

    // *** this part specifies where transfers should be stored ***
    config.Directories.DataSources.Add(
        new DirectoryConfiguration
        {
            Path = traceResource.RootPath,
            Container = "traces",
            DirectoryQuotaInMB = 100
        });
    config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(10);

    DiagnosticMonitor.Start("DiagnosticsConnectionString", config);

    return base.OnStart();
}  

In order for this to work, you have to create a LocalStorage node to store these files in your ServiceDefinition.csdef:

<LocalStorage name="TraceFiles" sizeInMB="100" cleanOnRoleRecycle="true" />

and you need to have a way to transfer these files to some place where you can get to them, because they are not available in the storage account, but on a local resource folder on the VM itself. I accomplish that with a webpage that allows me to download local resource files.

Right, sorted!

This post explains all: http://social.msdn.microsoft.com/Forums/pl-PL/windowsazuredata/thread/d3f2f1d7-f11e-4840-80f7-f61dc11742fb

It's because in Azure SDK 1.3 upwards the listeners are different in the webrole.cs file from the rest of the web app due to it running fully in IIS. If I add trace items to the web app itself the table WADLogsTable appears with my trace information.

I had similar problems myself, which the above posts didn't answer for me. I put together a blog post outlining the steps I took to get Diagnostics working with SDK 1.6

Windows Azure Diagnostics with SDK 1.6 for WebRoles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!