Is it possible to download or search application logs in Cloud Foundry

痴心易碎 提交于 2019-12-07 12:51:49

问题


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.

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

Thanks, Kinjal


回答1:


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

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.



来源:https://stackoverflow.com/questions/13739804/is-it-possible-to-download-or-search-application-logs-in-cloud-foundry

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!