对于 Azure Compute Emulator 中的任何工作角色,我似乎无法将任何输出消息发送到控制台窗口。我正在运行 Azure SDK 2.2,并从模板创建了一个新的 Worker 角色,并且没有任何内容打印到控制台窗口。我看到的唯一消息是关于面料的。
[fabric] Role Instance: deployment22(58).WindowsAzure2.TestWorkerRole.0
[fabric] Role state Started
我已经尝试过 Console.WriteLine 和 Trace.WriteLine 都没有工作。
using System.Linq;
using System.Net;
using System.Threading;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
using Microsoft.WindowsAzure.Storage;
namespace TestWorkerRole
{
public class WorkerRole : RoleEntryPoint
{
public override void Run()
{
// This is a sample worker implementation. Replace with your logic.
Trace.TraceInformation("TestWorkerRole entry point called", "Information");
Console.WriteLine("Hello World");
while (true)
{
Thread.Sleep(10000);
Trace.TraceInformation("Working", "Information");
Console.WriteLine("Inside loop");
}
}
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.
return base.OnStart();
}
}
}