How do I write the output of nginx -t (config test) to a file?

linux, nginx

Solution

Nginx write this to `stderr`, not to `stdout`. Use `nginx -t 2> text.txt`

Problem

Running `nginx -t` will test the configuration for correct syntax and will output a message describing the error if there is one or will say that syntax is ok. I want to have that output written to a file and I tried: ``` nginx -t > test.txt ``` This command is creating my `text.txt` file without any content. How can I get that output in a file?

Original source