gpt4 book ai didi

asp.net-mvc-4 - Azure 诊断未将日志保存在 azure 表中

转载 作者:行者123 更新时间:2023-12-02 06:22:33 25 4
gpt4 key购买 nike

仅检查 Windows azure sdk 2.0 中引入的新功能 - 启用诊断。

刚刚使用 MVC 4 Web 角色创建了一个新的 Azure 云项目,并从配置部分启用了诊断,但没有任何日志保存在 Azure 表上 - WADLogsTable、WADDiagnosticInfrastructureLogsTable。

诊断.wadcfg

<?xml version="1.0" encoding="utf-8"?>
<DiagnosticMonitorConfiguration configurationChangePollInterval="PT1M" overallQuotaInMB="4096" xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<DiagnosticInfrastructureLogs />
<Directories>
<IISLogs container="wad-iis-logfiles" />
<CrashDumps container="wad-crash-dumps" />
</Directories>
<Logs bufferQuotaInMB="1024" scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Verbose" />
<WindowsEventLog bufferQuotaInMB="1024" scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Verbose">
<DataSource name="Application!*" />
</WindowsEventLog>
</DiagnosticMonitorConfiguration>

服务定义.csdef

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="AzureWebApp" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2013-03.2.0">
<WebRole name="MvcWebApp" vmsize="Small">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
</WebRole>
</ServiceDefinition>

ServiceConfiguration.Cloud.cscfg

<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="AzureWebApp" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="3" osVersion="*" schemaVersion="2013-03.2.0">
<Role name="MvcWebApp">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>

WebRole.cs——来自 MVC 应用程序

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace MvcWebApp
{
public class WebRole : RoleEntryPoint
{
public override void Run()
{
// This is a sample webrole implementation. Replace with your logic.

while (true)
{
Thread.Sleep(10000);
Trace.WriteLine("Working", "Information");
}
}

public override bool OnStart()
{
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

Trace.WriteLine("Starting Web Role ...", "Information");

return base.OnStart();
}
}
}

我期待 Trace.WriteLine 错误,即“正在启动 Web 角色...”和“正在工作”到保存在 azure 表 - WADLogsTable 中。

任何帮助将不胜感激。

谢谢

巴哈维什

最佳答案

如果您部署 diagnostics.wadcfg 文件,则无需向 OnStart() 方法添加任何自定义检测代码。

问题出在包含 "DevelopmentStorage=true"ServiceConfiguration.Cloud.cscfg 文件中 - 将其替换为您的真实存储帐户或确保您的部署工具做到了。

关于asp.net-mvc-4 - Azure 诊断未将日志保存在 azure 表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16899093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com