1. 程式人生 > >logstash啟動報配置檔案錯誤Expected one of #, input, filter, output at line 1, column 1 (byte 1) after

logstash啟動報配置檔案錯誤Expected one of #, input, filter, output at line 1, column 1 (byte 1) after

執行環境:windows環境下

在部署logstash到伺服器的時候遇到這個問題,就是配置檔案什麼的都寫好了執行,然後出錯如圖:


然後根據提示去找配置檔案哪裡出現問題,配置檔案的圖如下:


結果找了老半天沒發現錯誤,於是用命令:logstash -f ../config/logstash-simple-dev.conf -t

去測試配置檔案是否正常。結果顯示無效配置檔案,也就是說配置檔案出錯了


提示Expected one of #, input, filter, output at line 1, column 1 (byte 1) after 。

可是我第一行沒錯啊,是以input開頭的啊。最後經過各種測試各種排查(難受)發現是檔案編碼的問題。原來我這個配置檔案logstash-simple-dev.conf的編碼是UTF-8 BOM也就是第一行就東西的只是我們看不到而已,解決方案就是把檔案換成UTF-8編碼格式就行無Bom模式的。

問題:配置檔案提示出錯Expected one of #, input, filter, output at line 1, column 1 (byte 1) after 。

解決方案:檔案編碼格式問題導致第一行有隱藏檔案頭,改為UTF-8無BOM模式(也就是UTF-8模式就行)。