Logstash crashes when I run .bat file from powershell

Below is the error that I get when I try to run logstash after downloading the .zip file from the official website.

.\logstash.bat -f logstash.conf                                     
Using JAVA_HOME defined java: C:\Program Files\Java\jdk-16.0.1\ 
WARNING, using JAVA_HOME while Logstash distribution comes with a bundled JDK                                           
Error: Could not find or load main class Files\Apache                                                                   
Caused by: java.lang.ClassNotFoundException: Files\Apache                                                               
"error: jvm options parser failed; exiting"

What can be done here? Where do I add Files/Apache and what does Files/Apache contain?

This is my logstash.conf file

# Read input from filebeat by listening to port 5044 on which filebeat will send the data
input {
    beats {
	    type => "test"
        port => "5044"
filter {
  #If log line contains tab character followed by 'at' then we will tag that entry as stacktrace
  if [message] =~ "\tat" {
    grok {
      match => ["message", "^(\tat)"]
      add_tag => ["stacktrace"]
output {
  stdout {
    codec => rubydebug
  # Sending properly parsed log events to elasticsearch
  elasticsearch {
    hosts => ["localhost:9300"]

It's likely because of the space in your directory name, try removing that.

I realize this is not your decision, Mark, but although that is true, it is really a bug in logstash. Saying "do not have a space in the install path" when spaces in the install path have been absolutely standard on Windows for years is not cool. There are only eight .bat files, totalling less than 6 KB of text. It would not be a major effort to test and fix them. Some cases have already been fixed!

There will be many variants of this, but if you install logstash, cd to the bin directory and run

.\logstash -f logstash.conf

then cmd barfs with

\logstash-7.14.0\logstash-core\lib\jars\animal-sniffer-annotations-1.14.jar was unexpected at this time.

that is due to the :concat function in logstash.bat not handling arguments with spaces


expands to

set CLASSPATH=c:\Program Files (x86)\logstash-7.14.0\logstash-core\lib\jars\animal-sniffer-annotations-1.14.jar

logstash.bat already has setlocal enabledelayedexpansion, so how hard is it to do

set CLASSPATH=!~1!

instead? Of course that just gets you onto setup.bat, where

echo "Using bundled JDK: "c:\Program Files (x86)\logstash-7.14.0\jdk\bin\java.exe"""

blows up, but again, it is not much work to turn on enabledelayedexpansion in that bat file too and make it handle spaces in the directory name.

Fair point and I don't disagree with you at all!

I did like Mark pointed out; removed the spaces in the path of both my JAVA_HOME and where logstash lives. It still throws the same error.

I also tried making changes listed by Badger in logstash.bat and the error I get still persists. Now he mentioned making similar changes in other batch files but I'm not familiar with writing batch files so I'm stuck.

Please suggest something that can be done here.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.