简体   繁体   中英

Azure web app (nodejs) logs don't appear in blob storage but webjob logs do

I configured Azure Web App Application Logging (Diagnostics logs).

https://docs.microsoft.com/en-us/azure/app-service/web-sites-enable-diagnostic-log

I have a nodejs backend api (express) and a couple of webjobs hosted on the same webapp.

I use console.info/console.error in the code for logging.

In the logstream/console in the portal I can see that logs coming from the webjobs are formatted with date, pid, level, ... but logs coming from the actual application are not formated.

Example of 2 console.info. First is from the api and 2nd from one webjob :

Start handling command DeleteCustomerCommand

2018-01-12T17:02:16 PID[9484] Information CustomerDeletedEvent handled

The problem is that in the blob storage, only the logs coming from webjobs are stored. I suppose this format is a requirement from Azure.

Do you know why the console.info behaves differently ? Can I do something to have the same behavior in the api ?

Do you know why the console.info behaves differently?

Azure WebJobs and Azure Web Apps actually run in the different context. WebJobs is hosted on the Kudu SCM site, and it is executed by Kudu API that captures the script log and formats it for you; while Web Apps is hosted on Microsoft IIS, and there's nothing built into the iisnode module to do this.

Can I do something to have the same behavior in the api?

You'll need to look into other modules to provide a richer formatting experience. For example: winston . Also, there is an Azure blob storage transport for winston.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM