我一直在尝试让我的 MVC 项目使用 azure 进行日志记录,但到目前为止还没有取得太大的成功。
我的ServiceConfiguration.Cloud.cscfg
文件中有一个诊断连接字符串,它指向我的 blob 存储:
...
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.DiagnosticsConnectionString" value="**ConectionString**" />
</ConfigurationSettings>
我web.config
的跟踪设置
...
<tracing>
<traceFailedRequests>
<remove path="*"/>
<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 timeTaken="00:00:15" statusCodes="400-599" />
</add>
</traceFailedRequests>
</tracing>
</system.webServer>
我WebRole.cs
的有以下内容
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
namespace MvcWebRole1
{
public class WebRole : RoleEntryPoint
{
public override bool OnStart()
{
// Get the factory configuration so that it can be edited
DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();
// Set scheduled transfer interval for infrastructure logs to 1 minute
config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(1);
// Specify a logging level to filter records to transfer
config.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
// Set scheduled transfer interval for user's Windows Azure Logs to 1 minute
config.Logs.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(1);
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.DiagnosticsConnectionString", config);
//RoleEnvironment.Changing += this.RoleEnvironmentChanging;
return base.OnStart();
}
}
}
但我没有看到任何诊断日志
该mam
文件夹只包含一个MACommanda.xml
和一个MASecret
,vsdeploy
文件夹是空的,并且wad-control-container
每个部署都有一个文件。
我错过了什么/做错了什么吗?
我一直在尝试遵循http://msdn.microsoft.com/en-us/library/windowsazure/gg433048.aspx的指南,特别是http://channel9.msdn.com/learn/courses/Azure/Deployment/ DeployingApplicationsinWindowsAzure/Exercise-3-Monitoring-Applications-in-Windows-Azure
更新:
我发现以下可能是问题的一部分
未正确收集 IIS7 日志 - http://msdn.microsoft.com/en-us/library/hh134842
虽然这应该只说明 404s 不工作,但故障定义为 15 秒,我的控制器操作中的 17 秒睡眠应该仍然被记录