Tips – parse log file tips

Posted by AllenWei | Posted in Tips | Posted on 15-02-2010-05-2008

View Comments




<brseparate variables by “|” # Analyze
field_names = [:level, :time, :pid, :location, :token, :query, :proxy, :action, :cost, :msg]
log_data = Hash[*field_names.zip(parts).flatten]

Then you can easily get all your variables

puts log_data[:level]
puts log_data[:time]
  1. Combined log files analyze
#code in analyzer.rb
ARGF.each_line do |line|
  puts line
end

Then

ruby analyzer.rb log1.log log2.log


Ads Plugin created by Jake Ruston's Wordpress Plugins - Powered by and football database.