Search code examples
crystal-lang

How to start process with output to log file?


I try to do it this way, but nothing happens.

Process.new("app_name >> app_name.log")

What is the proper syntax?


Solution

  • You can do this entirely within Crystal without spawning a shell using the output option of Process.new.

    File.open("app_name.log", "a") do |file|
      Process.new("app_name", output: file)
    end