4

TraceSourceAzure エミュレーター ( consoley ) ウィンドウにログ情報を表示しようとしています。

どのTraceSource行も表示されません。ストックTraceラインとさまざまな低レベルの azure メッセージのみ。

コードスニペットを含む、リポジトリへの私の手順は次のとおりです。

  1. ファイル -> 新規 -> Cloud Service (SDK 2.0) -> (worker ロールを追加)。
  2. WorkerRole に TraceSource を追加します。
  3. トレース データで app.config を更新します。
  4. 再生/公開。

他のすべてのデフォルトコードがそこにあることに.csfg注意してください。UseDevelopmentStorage=true

ワーカー ロール コード。

TraceSourceこれは、私のコードが追加された STOCK DEFAULT CODEです...

using System.Diagnostics;
using System.Net;
using System.Threading;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace WorkerRole1
{
    public class WorkerRole : RoleEntryPoint
    {
        private TraceSource _traceSource;

        public override void Run()
        {
            _traceSource.TraceEvent(TraceEventType.Verbose, 0,
                                    "********************** 111111111111111111111 ******************* ");

            // This is a sample worker implementation. Replace with your logic.
            Trace.TraceInformation("WorkerRole1 entry point called", "Information");

            while (true)
            {
                _traceSource.TraceEvent(TraceEventType.Verbose, 0,
                                        "********************** 222222222222222222222 ******************* ");
                Thread.Sleep(10000);
                Trace.TraceInformation("Working", "Information");
            }
        }

        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections 
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.


            _traceSource = new TraceSource("Azure.WorkerRole", SourceLevels.All);

            return base.OnStart();
        }
    }
}

今app.config...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

    <system.diagnostics>

        <sharedListeners>
            <add name="AzureListener"
                 type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                <filter type="" />
            </add>
        </sharedListeners>

        <sources>
            <source name="Azure.WorkerRole" switchValue="Verbose" >
                <listeners>
                    <add name="AzureListener" />
                </listeners>
            </source>
        </sources>

    </system.diagnostics>
</configuration>

それでおしまい!実行して、traceSourceものが表示されないことを確認してください:(ものは..ですが、代わりに使用することで置き換えることが提案されているためTrace.Information、古い方法を使用したくありません。TraceTraceSource

サンプル出力。行だけが追加されていることに注意してくださいTrace(低レベルの azure のものと一緒に)。

ここに画像の説明を入力

4

0 に答える 0