是否可以在Cloud Foundry中下载或搜索应用程序日志 [英] Is it possible to download or search application logs in Cloud Foundry

查看:57
本文介绍了是否可以在Cloud Foundry中下载或搜索应用程序日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Cloud Foundry的新手,我试图找到一种方法来下载日志文件或在Cloud Foundry中搜索它们。

I am new to cloud foundry and am trying to find out of there is a way for downloading log files or search them in cloud foundry.

我知道我可以使用vmc文件打开日志文件,但是还有其他访问日志的方法吗?

I know that I can open the logs files using vmc files but is there any other way of accessing the logs?

谢谢,
Kinjal

Thanks, Kinjal

推荐答案

我认为最简单的方法是使用VMC客户端库 cfoundry。

I think the easiest way to do this is using the VMC client library, 'cfoundry'.

以下红宝石脚本连接并下载了三个主要日志:

The following ruby script connects and downloads the three main logs:

#!/usr/bin/env ruby

require 'rubygems'
require 'cfoundry'

creds = { :username => ARGV[0], :password => ARGV[1] }
app_name = ARGV[2]

files_to_dl = ['logs/staging.log', 'logs/stderr.log', 'logs/stdout.log']

c = CFoundry::Client.new "http://api.cloudfoundry.com"
c.login creds

app = c.app_by_name app_name

files_to_dl.each do |file|
  begin
    content = app.file(file)

    local_path = file.match(/\/([^\/]+)$/)[1]
    File.open(local_path, 'w') { |f| f.write(content) }

  rescue CFoundry::NotFound
    puts "404!"
  end
end

此脚本假定您使用的是最新版本的VMC (较旧的旧版本不使用cfoundry),并且在调用脚本时还传递了用户名,密码和应用程​​序名称。它将在本地写入远程文件的内容。

This script assumes you are using the latest version of VMC (older, legacy versions don't use cfoundry) and that you also pass in username, password and application name when calling the script. It will write the contents of the remote files locally.

这篇关于是否可以在Cloud Foundry中下载或搜索应用程序日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆