Azure NodeJS console log

a 夏天 提交于 2019-12-05 21:50:43

You can view your logs in real time if you use the azure SCM interface. This can usually be accessed on the following url

https://{{ name of webapp }}.scm.azurewebsites.net/api/logstream

All your console output from your application is redirected here.

You can also use curl:

curl -u {{ deploymentCredentialsUsername:deploymentCredentialsPassword }} https://webapp-name.acm.azurewebsites.net/api/logstream

Otherwise you could use the nodejs azure cli. Install it with

npm install -g azure-cli

Switch to asm mode:

azure config mode asm

Then you can proceed to look at the logs from your terminal:

azure site log tail {{ webapp name }}

You can add an item in iisnode.yml named logDirectory, set the value as iisnode for example, then the application will create a folder in this name in your root directory and store files with stdout and stderr captures in it. You can refer to https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml#L94 for the details for this configuration.

You can store logs in files whatever you need via console.log(), then the application will create a html file index.html in the log folder to provide logs. You can visit the logs via the URL: http://<you_app_name>.azurewebsites.net/<log_file_name>/index.html

Additionally, you can leverage Node.js console class to customize logger, refer to https://nodejs.org/api/console.html#console_new_console_stdout_stderr for the sample

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!