I'm currently writing a rest API in java that handles different processes, and what I'm trying to achieve is redirecting the output of a python process while it is running indefinitely to a .txt file. This is my current code:
File log = createLog(name);
File environment = new File(path);
Process process = new ProcessBuilder(exe,cmd,args).redirectOutput(log).directory(environment).start();
but nothing is written to the created log file. I know the process is being run, since if I switch redirectOuput with inheritIO the java process prints what the python process prints. The log file is also created successfully. What am I doing wrong, and how do I do it correctly?
Edit: To be clear, the process never finishes and i want the output of the process to continuously be piped to the log file.