I deployed my nodeJs bot to Bot Service recently, and i can't seems to figure out how to generate and view it's logs.
- when i try to enable logging, i constantly getting an unknown error
- Looking at the log files on the server, there is no file who logs the node application
- Tried to log to Application insights, without success.
help?
Assuming your bot is hosted through Azure via an App Service, you should be able to see logging from your NodeJS application by performing the following steps:
Enabling Logging
loggingEnabled: true
. This will enable your application to writestderr
andstdout
to the log stream.Accessing the Log Stream
Personally, I prefer using the Azure Command-Line Interface, which you can easily install using the node package manager or npm.
To install the Azure CLI, issue the following command on your terminal:
npm install -g azure-cli
or
sudo npm install -g azure-cli
if you need root permission.If you need more information on how to install the Azure CLI look here.
Now you have to log into your Azure account through the Azure CLI so that it can access your subscription. This is done via
azure login
.Once you have finished logging in through the command line, you need to switch to service management mode with the command
azure config mode asm
.Then you can use
azure site list
to get a list of your current Azure sites.In the list, find the site that you want the logs for, and find its name in the Name column. Then use the command
azure site log tail <sitename>
and the terminal will start to output live logs straight from your application!Other Options
The above method is only 1 of the 3 methods you can use to access these logs. If you want more information on the other 2 methods then follow this link.
That above link also contains a lot of the information I outlined in my post.
I hope this helped!