In the nodejs examples for Azure function apps, there is a passed in context obj to the function and it is possible to do context.log in the same manner as you can with console.log to output messages.
What is the difference between these two methods and does it matter which you use? Thx.
Context.Log (Method) Directs the DataFile object associated with the Context to log the values of the Context.
To view streaming logs in the portal, select the Platform features tab in your function app. Then, under Monitoring, choose Log streaming. This connects your app to the log streaming service and application logs are displayed in the window. You can toggle between Application logs and Web server logs.
To reduce latency, create the storage account in the same region as the function app. To improve performance in production, use a separate storage account for each function app. This is especially true with Durable Functions and Event Hub triggered functions.
By default, the data collected from your function app is stored in Application Insights. In the Azure portal, Application Insights provides an extensive set of visualizations of your telemetry data. You can drill into error logs and query events and metrics.
This documentation should answer your question :)
In Functions, you use the
context.logmethods to write trace output to the console. In Functions v2.x, trace outputs usingconsole.logare captured at the Function App level. This means that outputs fromconsole.logare not tied to a specific function invocation, and hence aren't displayed in a specific function's logs. They do, however, propagate to Application Insights. In Functions v1.x, you cannot use console.log to write to the console.
Long story short - context.log is best!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With