Reputation: 667
I am experimenting with WebJobs. I created a new WebJob project in Visual Studio 2015. Here is the code:
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")}");
}
}
As you can see I am using the Timers extension so that the function is called every one second.
When I run this locally (and assuming on Azure too) even though I have commented out the log.WriteLine in the function, there are logs created on the storage account I have created. There are output-logs with files showing empty text and there are host logs with information about the function.
Imagine that there is one of each log every second. How can I stop those logs from being written?
Upvotes: 0
Views: 798
Reputation: 27825
Please try to set the dashboard connection string to null as shown in the following example to disable logging.
var config = new JobHostConfiguration();
config.DashboardConnectionString = "";
config.UseTimers();
var host = new JobHost(config);
host.RunAndBlock();
Upvotes: 2