AzureLocalStorageTraceListener住在哪里?
我试图在我的Web服务中实现跟踪,但我得到了错误: 找不到类的类型 Host.AzureLocalStorageTraceListener,MyProject.Host 我有一个Web服务,它托管在azure中,但不遵循azure Web服务的通常结构 有一个azure项目,其webrole指向MyProject.Host。这是启动项目 有一个名为MyProject.Host的项目,其中包含服务的web.config和azure webrole 然后是MyProject.Service项目,它包含服务接口IService1和服务代码Service1.cs web.config中的代码是:AzureLocalStorageTraceListener住在哪里?,azure,diagnostics,Azure,Diagnostics,我试图在我的Web服务中实现跟踪,但我得到了错误: 找不到类的类型 Host.AzureLocalStorageTraceListener,MyProject.Host 我有一个Web服务,它托管在azure中,但不遵循azure Web服务的通常结构 有一个azure项目,其webrole指向MyProject.Host。这是启动项目 有一个名为MyProject.Host的项目,其中包含服务的web.config和azure webrole 然后是MyProject.Service项目,它包
<sharedListeners>
<add name="AzureLocalStorage" type="Host.AzureLocalStorageTraceListener, MyProject.Host"/>
</sharedListeners>
我有两个想法
非常感谢 首先,您必须知道您需要自己创建AzureLocalStorageTraceListener,此类不是Azure SDK的一部分:
using System;
using System.Diagnostics;
using System.IO;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
namespace MyProject.Host
{
public class AzureLocalStorageTraceListener : XmlWriterTraceListener
{
public AzureLocalStorageTraceListener()
: base(Path.Combine(AzureLocalStorageTraceListener.GetLogDirectory().Path, "MyProject.svclog"))
{
}
public static DirectoryConfiguration GetLogDirectory()
{
DirectoryConfiguration directory = new DirectoryConfiguration();
directory.Container = "wad-tracefiles";
directory.DirectoryQuotaInMB = 10;
directory.Path = RoleEnvironment.GetLocalResource("CustomLogs").RootPath;
return directory;
}
}
}
我建议您将此文件添加到您的MyProject.Host项目中,因为此文件与主机相关,而与服务无关。添加此文件后,我们知道:
- 程序集:MyProject.Host
- 类:MyProject.Host.AzureLocalStorageTraceListener(这基于名称空间,而不是程序集的名称)
<sharedListeners>
<add name="AzureLocalStorage" type="MyProject.Host.AzureLocalStorageTraceListener, MyProject.Host"/>
</sharedListeners>
注意:AzureLocalStorageTraceListener类中的代码假设您有一个名为CustomLogs的本地资源。首先,您必须知道您需要自己创建AzureLocalStorageTraceListener,该类不是Azure SDK的一部分:
using System;
using System.Diagnostics;
using System.IO;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
namespace MyProject.Host
{
public class AzureLocalStorageTraceListener : XmlWriterTraceListener
{
public AzureLocalStorageTraceListener()
: base(Path.Combine(AzureLocalStorageTraceListener.GetLogDirectory().Path, "MyProject.svclog"))
{
}
public static DirectoryConfiguration GetLogDirectory()
{
DirectoryConfiguration directory = new DirectoryConfiguration();
directory.Container = "wad-tracefiles";
directory.DirectoryQuotaInMB = 10;
directory.Path = RoleEnvironment.GetLocalResource("CustomLogs").RootPath;
return directory;
}
}
}
我建议您将此文件添加到您的MyProject.Host项目中,因为此文件与主机相关,而与服务无关。添加此文件后,我们知道:
- 程序集:MyProject.Host
- 类:MyProject.Host.AzureLocalStorageTraceListener(这基于名称空间,而不是程序集的名称)
<sharedListeners>
<add name="AzureLocalStorage" type="MyProject.Host.AzureLocalStorageTraceListener, MyProject.Host"/>
</sharedListeners>
注意:AzureLocalStorageTraceListener类中的代码假设您有一个名为CustomLogs的本地资源,这太棒了。非常感谢你!!太棒了。非常感谢你!!