Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To obtain the log category while executing Azure Functions offline, you can use the logging feature provided by Azure Functions. Here are the steps:

  1. Install the Azure Functions Core Tools: If you haven't installed the Azure Functions Core Tools on your local machine, you can download and install them from the Azure Functions Core Tools page.

  2. Create a new Azure Function: Choose your language and template to create a new Azure Function in the local dev environment.

  3. Add logging statements: Add logging statements to your Azure Function code to log any specific log category, using the logging framework of your language.

  4. Start the Azure Function: Start the Azure Function in the local dev environment using the Azure Functions Core Tools.

  5. View the log output: View the log output in the console that displays the category of the logs.

For instance, in Node.js, you can use the following function to log messages with different levels:

module.exports = function (context, req) {
    context.log('This is a log message'); // logging level: information
    context.log.warn('This is a warning message'); // logging level: warning
    context.log.error('This is an error message'); // logging level: error
    context.log.verbose('This is a verbose message'); // logging level: verbose
    context.log.debug('This is a debug message'); // logging level: debug
    context.log.silly('This is a silly message'); // logging level: silly
    context.res = {
        status: 200,
        body: "Hello World!"
    };
    context.done();
};

In the output window, you can observe the category of the log message, such as "information", "warning", "error", "verbose", "debug", or "silly".