我查看了很多不同的 Azure 和 Wcf 服务示例。我已经配置了一个跟踪监听器,并且很多跟踪信息出现在相关的日志文件中;但是,我没有看到 Trace.WriteLine 请求的结果。我确实在 Azure 调试器输出面板中看到了我的 Trace.WriteLine 请求。这些请求的输出保存在哪里?
从我的 Web.config
<system.diagnostics>
<sources>
<source propagateActivity="false" name="System.ServiceModel"
switchValue="Verbose,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="AzureLocalStorage">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Information">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="AzureLocalStorage">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add type="WCFServiceWebRole1.AzureLocalStorageTraceListener, WCFServiceWebRole1"
name="AzureLocalStorage">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
从我的 AzureLocalStorageTraceListener.cs
public class AzureLocalStorageTraceListener : XmlWriterTraceListener
{
public AzureLocalStorageTraceListener()
: base(Path.Combine(AzureLocalStorageTraceListener.GetLogDirectory().Path, "WCFServiceWebRole1.svclog"))
{
}
public static DirectoryConfiguration GetLogDirectory()
{
DirectoryConfiguration directory = new DirectoryConfiguration();
directory.Container = "wad-tracefiles";
directory.DirectoryQuotaInMB = 10;
directory.Path = RoleEnvironment.GetLocalResource("WCFServiceWebRole1.svclog").RootPath;
return directory;
}
}