尝试在Windows上运行logstash 5时:
C:\发展\工作空间\ logstash> C:\开发\ SOFTWARE \ logstash-5.1.2 \ BIN \ logstash.bat -f robot-log.js
它出现以下错误:
Could not find log4j2 configuration at path /Development/Software/logstash-5.1.2/config/log4j2.properties. Using default config which logs to console
15:03:53.667 [[main]-pipeline-manager] INFO logstash.filters.multiline - Grok loading patterns from file {:path=>"C:/Development/Software/logstash-5.1.2/vendor/bundle/jruby/1.9/gems/logstash-patterns-core-4.0.2/patterns/aws"}
15:03:53.684 [[main]-pipeline-manager] INFO logstash.filters.multiline - Grok loading patterns from file {:path=>"C:/Development/Software/logstash-5.1.2/vendor/bundle/jruby/1.9/gems/logstash-patterns-core-4.0.2/patterns/bacula"}
15:03:53.693 [[main]-pipeline-manager] INFO logstash.filters.multiline - Grok loading patterns from file ...
该文件实际存在于目录中。为什么logstash无法找到它?
注意: 我最初虽然这是Ruby使用Linux路径分隔符的问题。但是,正如@Stefan在下面的评论中指出的那样,Ruby甚至在Windows上接受了Linux样式路径
答案 0 :(得分:1)
这似乎是最新版本的logstash中的一个错误。在logger.rb
下,它有以下代码:
def self.initialize(config_location)
@@config_mutex.synchronize do
if @@logging_context.nil?
file_path = URI(config_location).path
if ::File.exists?(file_path)
logs_location = java.lang.System.getProperty("ls.logs")
puts "Sending Logstash's logs to #{logs_location} which is now configured via log4j2.properties"
@@logging_context = Configurator.initialize(nil, config_location)
else
# fall back to default config
puts "Could not find log4j2 configuration at path #{file_path}. Using default config which logs to console"
@@logging_context = Configurator.initialize(DefaultConfiguration.new)
end
end
end
end
对URI.path
的调用似乎有问题,因为根据documentation,当输入为/posts
时,它会返回http://foo.com/posts?id=30&limit=5#time=1305298413
我不是Ruby程序员所以我不知道为什么logstash devs在这里使用它。但只需将file_path = URI(config_location).path
替换为file_path = config_location
即可解决问题。
C:\Development\workspace\logstash>C:\Development\Software\logstash-5.1.2\bin\logstash.bat -f robot-log.js
Sending Logstash's logs to C:/Development/Software/logstash-5.1.2/logs which is now configured via log4j2.properties
[2017-01-24T15:22:04,754][INFO ][logstash.filters.multiline] Grok loading patterns from file {:path=>"C:/Development/Software/logstash-5.1.2/vendor/bundle/jruby/1.9/gems/logstash-patterns-core-4.0.2/patterns/aws"}
[2017-01-24T15:22:04,769][INFO ][logstash.filters.multiline] Grok loading patterns from file {:path=>"C:/Development/Software/logstash-5.1.2/vendor/bundle/jruby/1.9/gems/logstash-patterns-core-4.0.2/patterns/bacula"}
[2017-01-24T15:22:04,772][INFO ][logstash.filters.multiline] Grok loading patterns from file {:path=>"C:/Development/Software/logstash-5.1.2/vendor/bundle/jruby/1.9/gems/logstash-patterns-core-4.0.2/patterns/bro"}