Logging events
In any application, logs are a very useful debugging and monitoring tool, however, they become even more crucial in serverless compute. As we will see in this chapter, it is not always easy to debug the functions locally, and it isn't always easy to simulate parallel execution of functions when they are triggered at scale. Given the asynchronous, cloud-based, and highly parallelized nature of the serverless code, the log
statements become one of our most powerful tools for identifying and correcting errors.
Azure Function templates come preconfigured with the TraceWriter log
parameter, which is based on the Microsoft.Azure.WebJobs.Script.Intercepting.TraceWriter
class, implemented in the WebJobs SDK.
The usage of the TraceWriter
class is not limited solely to functions and WebJobs. You can start leveraging the TraceWriter
class in other parts of your application (such as Web UI) by installing the WebJobs NuGet package. This would allow you to log events consistently across multiple...