0

私はさまざまな 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;
    }
}
4

1 に答える 1

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. スイッチの値が正しいことを確認してください (開始するには値Allを試すことができます) 。

  3. エミュレーターのログ レベルを変更します (画面の右上にあるアイコンを右クリックします)。

ログ レベルの変更

于 2012-07-25T18:31:51.617 に答える