There are multiple ways to enable logging inside your Azure Web Job.
Console.WriteLine
One option that works if you created a C# console application, is using the Console.WriteLine() or Console.Write() methods on the Console object.
Inject a TextWriter
Another option is injecting a TextWriter into one of the WebJobs methods:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void ShutdownMonitor( | |
[QueueTrigger("%ShutdownQueueName%")] string message, | |
TextWriter log, | |
CancellationToken cancelToken) | |
{ | |
log.WriteLine("From function: Received a message: " + message); | |
while (!cancelToken.IsCancellationRequested) | |
{ | |
log.WriteLine("From function: Cancelled: No"); | |
Thread.Sleep(2000); | |
} | |
// Perform the graceful shutdown logic here | |
log.WriteLine("From function: Cancelled: Yes"); | |
} |