如何获取已部署的app的debugging日志?

Ivar_PredixCN 2017-08-28 09:42:19
PROBLEM

Things are not working and you want more insight into what may be happening with your application that won't start, won't deploy, or has recently failed in some way.

STEPS
There are several things you could do to prepare for the situation where your app and services start to misbehave.

(a) Turn on Cloud Foundry Tracing for the CLI to get logs of staging and buildpack issues during REST API calls.

For bash shells it might look like this:

export CF_TRACE=~/cf-trace.log
or for csh/tcsh:

setenv CF_TRACE ~/cf-trace.log

You will receive a lot of details when you run cf commands from then on that will help you and others debug what might be happening.

(b) Use the cf logs and cf logs --recent commands.

The cf logs will start streaming / tailing log details from your application's STDOUT and STDERR as any output is generated by the app and container. If you want to just show past log output the --recent will dump anything still in the log buffer.

(c) Use the cf files command to download log files (for DEA apps).

From your running application some log files will persist to files in the container temporarily. You can see a list of them by running cf files <App Name> /logs and then download them one at a time: cf files <App Name> /logs/staging_task.log > staging_task.log.

(d) Create an instance of the logstash logging service.
https://www.predix.io/services/service.html?id=1184

See the logging documentation to bind the ELK stack: elastic search, logstash, and kibana for your application.
https://docs.predix.io/en-US/content/service/operations/logging/
(e) Make sure you send important logging information from your application. While the above steps will help you access the logs, if you aren't outputting anything to the logs it will have limited value.

This can range from simple print statements to more robust logging frameworks like log4j in Java, log4js in JavaScript, or logging in python that produce logs in parseable formats for easier analysis.

DEPENDENCIES

Cloud Foundry CLI

You can retrieve logs for your pushed apps/services, but you will not be able to see logs for the service instances which you depend on such as Time Series, Asset, or UAA.

RESOURCES
Logstash Logging Service Documentation
https://docs.predix.io/en-US/content/service/operations/logging/
Cloud Foundry Documentation for Troubleshooting Application Deployment and Health
https://docs.cloudfoundry.org/devguide/deploy-apps/troubleshoot-app-health.html
Pivotal Web Service Documentation for Application Logging in Cloud Foundry
https://docs.run.pivotal.io/devguide/deploy-apps/streaming-logs.html
...全文
37 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

163

社区成员

发帖
与我相关
我的任务
社区描述
GE的Predix平台整合云计算可扩展性、大数据管理和高级分析技术来助力新一代的数字化企业。结合GE自己作为全球工业界领导者的经验,Predix云平台为开发高级工业应用程序提供可连接性、安全和高性能。
云计算大数据 技术论坛(原bbs)
社区管理员
  • GE Predix工业互联网开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧