2012-07-25 100 views
0

我看了很多不同的Azure和Wcf服务示例。我已经配置了一个跟踪监听器,并且跟踪信息出现在关联的日志文件中;但是,我没有看到我的Trace.WriteLine请求的结果。我在Azure调试器输出面板中看到了我的Trace.WriteLine请求。这些请求的输出在哪里持续存在?Azure wcf服务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; 
    } 
} 

回答

0

AzureLocalStorageTraceListener创建只需登录到* .svclog文件。如果你想输出日志的模拟器有一些事情你应该照顾:

  1. 的DevelopmentFabricTraceListener添加到您的共享听众(这也将为1.7 SDK工作)

    <add type="Microsoft.ServiceHosting.Tools.DevelopmentFabric.Runtime.DevelopmentFabricTraceListener, Microsoft.ServiceHosting.Tools.DevelopmentFabric.Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Emulator"> 
        <filter type="" /> 
    </add> 
    
  2. 确保开关值是正确的(你可以尝试值所有上手)

  3. 变化在模拟器中日志记录级别(通过右键点击屏幕右上角的图标)。

Change Logging Level