Windows Azure的跟踪日志不工作 [英] Windows Azure Trace Log not working
问题描述
我敢肯定,我错过了一些东西简单,但我不能让简单的Trace.WriteLine工作在Azure上。
I'm sure I have missed something simple but I can't get simple Trace.WriteLine to work on Azure.
步骤我已经采取了:
Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString已成立了我们的Azure存储帐户
Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString has been set up to our Azure storage account
导入模块诊断为服务定义文件。
Import Module Diagnostics to service definition file.
网络配置
:
<system.diagnostics>
<switches>
<add name="logLevel" value="4" />
</switches>
<trace autoflush="false" indentsize="4">
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
</add>
</listeners>
</trace>
</system.diagnostics>
WebRole.cs
public class WebRole : RoleEntryPoint
{
public override bool OnStart()
{
String wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));
RoleInstanceDiagnosticManager roleInstanceDiagnosticManager =
cloudStorageAccount.CreateRoleInstanceDiagnosticManager(
RoleEnvironment.DeploymentId,
RoleEnvironment.CurrentRoleInstance.Role.Name,
RoleEnvironment.CurrentRoleInstance.Id);
DiagnosticMonitorConfiguration diagnosticMonitorConfiguration =
roleInstanceDiagnosticManager.GetCurrentConfiguration();
diagnosticMonitorConfiguration.Directories.ScheduledTransferPeriod =
TimeSpan.FromMinutes(5d);
diagnosticMonitorConfiguration.Logs.ScheduledTransferPeriod =
TimeSpan.FromMinutes(1d);
diagnosticMonitorConfiguration.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
roleInstanceDiagnosticManager.SetCurrentConfiguration
(diagnosticMonitorConfiguration);
Trace.WriteLine("This is the message");
Debug.Write("This is the debug message");
System.Diagnostics.Trace.TraceError("message2");
System.Diagnostics.Trace.TraceWarning("message warning");
System.Diagnostics.Trace.TraceInformation("message warning");
Trace.Flush();
return base.OnStart();
}
}
解决方案被编译为发布。
Solution is compiled as release.
当我查看存储帐户,我可以看到一个名为WADDirectoriesTable和三个斑点表中的对象创建名为vsdeploy,WAD控制容器,是-IIS-日志文件。
When I view the objects in the storage account I can see a Table called WADDirectoriesTable and three blobs created called vsdeploy, wad-control-container and was-iis-logfiles.
没有,看起来像我的跟踪信息。
Nothing that looks like my Trace information.
感谢
推荐答案
右键,排序!
本文章解释一切:<一href="http://social.msdn.microsoft.com/Forums/pl-PL/windowsazuredata/thread/d3f2f1d7-f11e-4840-80f7-f61dc11742fb" rel="nofollow">http://social.msdn.microsoft.com/Forums/pl-PL/windowsazuredata/thread/d3f2f1d7-f11e-4840-80f7-f61dc11742fb
这是因为在Azure的SDK 1.3以上的听众是来自Web应用程序的其余部分webrole.cs文件不同,由于它完全运行在IIS中。如果我添加跟踪项目到Web应用程序本身的表WADLogsTable似乎与我的跟踪信息。
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.
这篇关于Windows Azure的跟踪日志不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!