简体   繁体   English

Azure Web App Service日志记录中的Spring Boot MVC无法按预期工作

[英]Spring Boot MVC in Azure Web App Service logging is not working as expected

We are deploying a Spring MVC application using Spring Boot, to Azure Web App Service. 我们正在使用Spring Boot将Spring MVC应用程序部署到Azure Web App Service。 We have the application deployed, and can hit the end points, but are unable to see logging output. 我们已经部署了应用程序,可以到达终点,但是看不到日志记录输出。 Logging is implemented with a logback.xml file and the logging levels are set in the application.properties file. 使用logback.xml文件实现日志记录,并且在application.properties文件中设置日志记录级别。

Note that logging works perfectly when deploying the application to Tomcat on a VM. 请注意,将应用程序部署到VM上的Tomcat时,日志记录工作完美。 The logging output, when logged to stdout, is accessible in the catalina.out file. 记录到stdout的记录输出可在catalina.out文件中访问。 But, when the application is pushed to Azure Web App Services, no logging output is accessible from the catalina.log file, nor anywhere else. 但是,将应用程序推送到Azure Web App Services时,无法从catalina.log文件或任何其他位置访问日志记录输出。

Unfortunately, the documentation for deploying Spring Boot apps to azure can be summed up as 'scant to none', but we need to accomplish this for our customer. 不幸的是,将Spring Boot应用程序部署到Azure的文档可以总结为“几乎没有”,但是我们需要为我们的客户实现这一点。 The documentation that is there, regarding logging for java, seems to want you to use Application Insights . 那里有关Java日志记录的文档似乎希望您使用Application Insights Unfortunately, this is another service that costs money. 不幸的是,这是另一项收费的服务。 There has to be a way to view standard logs from a java app in Azure Web App Services. 必须有一种方法可以从Azure Web App Services中的Java应用程序查看标准日志。

Is there anyone out there who has any experience with this? 那里有人对此有经验吗? Much thanks in advance. 提前非常感谢。

Set the logging level within the application.properties file within Spring Boot. 在Spring Boot的application.properties文件中设置日志记录级别。

logging.level=DEBUG
logging.level.org.springframework=DEBUG

Then within the web.config file set where the log whould be stored, ie 然后在web.config文件中设置要存储日志的位置,即

-Dlogging.file="%HOME%\LogFiles\boot.log"

Then on the Console tab of the web application within Microsoft Azure you can specify that you would like to tail the log. 然后,在Microsoft Azure中的Web应用程序的“控制台”选项卡上,您可以指定要尾随日志。

tail D:\home\LogFiles\boot.log

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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