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
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
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.