さて、私がしたことは、WebRoleファイルで設定をセットアップすることであり、web.configに追加したコードはこの構成です
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<tracing>
<traceFailedRequests>
<add path="*">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module" verbosity="Verbose" />
</traceAreas>
<failureDefinitions verbosity="Warning" statusCodes="400-599" />
</add>
</traceFailedRequests>
</tracing>
</system.webServer>
次に、この構成でOnstartメソッドを実装します。
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 config = roleInstanceDiagnosticManager.GetCurrentConfiguration();
//Add Events
config.WindowsEventLog.DataSources.Add("System!*");
config.WindowsEventLog.DataSources.Add("Application!*");
config.WindowsEventLog.ScheduledTransferLogLevelFilter = LogLevel.Error;
config.WindowsEventLog.ScheduledTransferPeriod =TimeSpan.FromSeconds(15.0);
config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
config.Logs.ScheduledTransferPeriod = TimeSpan.FromSeconds(15.0);
//transfer the IIS and IIS Failed Request Logs
config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1.0);
roleInstanceDiagnosticManager.SetCurrentConfiguration(config);
return base.OnStart();
}
また、WerRole設定でConnectionStringを確認することをお勧めします。次のようになります。
"DefaultEndpointsProtocol = http; AccountName = myAccount; AccountKey = 8zTMPlQ8N76cEUNGLYhIvPf8lDmmTnCm7BICX / xtPmdr9vN7elOvZS5N2njtg + tbStoCoe30doN0sCrE1LHcsd =="
また
"UseDevelopmentStorage = true"
開発環境に取り組みたい場合
また、詳細については、このサイトをご覧ください。
http://robindotnet.wordpress.com/2011/02/16/azure-toolssdk-1-3-and-iis-logging/