0
我正在試驗WebJobs。我在Visual Studio 2015中創建一個新的WebJob項目下面是代碼:是否是Azure WebJob配置來控制日誌?
public class Program
{
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
public static void Main()
{
JobHostConfiguration config = new JobHostConfiguration();
config.Tracing.ConsoleLevel = TraceLevel.Info;
Environment.SetEnvironmentVariable("AzureWebJobsEnv", "Development");
if(config.IsDevelopment)
{
config.UseDevelopmentSettings();
}
config.UseTimers();
JobHost host = new JobHost(config);
host.RunAndBlock();
}
}
public class Functions
{
public static void GetMarketData([TimerTrigger("00:00:01")] TimerInfo timer, TextWriter log)
{
//log.WriteLine($"Market data retrieved at {DateTime.Now.ToString("yyMMdd HH:mm:ss")}");
}
}
正如你可以看到我使用的定時器擴展,使該功能被稱爲每隔一秒。
當我在本地運行(並假設在Azure上)時,即使我已經註釋掉函數中的log.WriteLine,也會在創建的存儲帳戶上創建日誌。有輸出日誌文件顯示空文本,並有主機日誌與關於該功能的信息。
想象一下,每秒有一個日誌。我怎樣才能阻止這些日誌被寫入?
謝謝。這阻止了應用程序日誌被寫入。如果我想在我認爲合適的地方添加日誌記錄,我假設我將不得不手動寫入blob。 – Apollonas