Logging from ASP.NET 5 application hosted as Azure Web App

后端 未结 3 1813
刺人心
刺人心 2021-02-04 02:00

I have an ASP.NET 5 Web API that I host in Azure as a Web App. I want to log messages from my code using Azure Diagnostics. There are multiple article including Azure docs that

3条回答
  •  Happy的楠姐
    2021-02-04 02:14

    If you look at your web.config, it probably has stdoutLogEnabled="false". If you set that to true, then anything that is written to standard output will be written to a file. And the stdoutLogFile determines where it goes, which by default is under d:\home\logfiles.

    Now you need to make sure that your logging actually goes to stdout. Doing Console.WriteLine would definitely work. I think it's probably possible to also configure things via ILoggerFactory in your startup.cs to make logs go to stdout.

提交回复
热议问题