Search code examples
windowspowershellcmdstdoutio-redirection

How to log wkhtmltopdf command output to file on Windows?


I'm trying to log the output of the wkhtmltopdf EXE to a file however the log file it creates is just blank lines with no actual output. I can see the output in the CMD window but the file the command is redirected to is blank.

C:\PROGRA~1\wkhtmltopdf\bin\wkhtmltopdf >> C:\test.txt

In the CMD window I see the documentation for wkhtmltopdf, like the below:

Name: wkhtmltopdf 0.12.5 (with patched qt)

Synopsis: wkhtmltopdf [GLOBAL OPTION]... [OBJECT]...

but the output file has 16 blank lines?

I've tried various alternative ways of running the command, using cmd /c or the START command, tried with powershell as well but have had no joy so far.

Any help with this would be much appreciated, thank you!


Solution

  • I was able to resolve this by changing the command as follows, thanks to Cpt.Whale comment for pointing me in the right direction!

    C:\PROGRA~1\wkhtmltopdf\bin\wkhtmltopdf 1>> C:\test.txt 2>&1