I needed to debug an application that is run as a windows service registered by nssm. The behavior that I wanted to investigate occurred only in a production environment. So, I had to debug it without VSCode.
It is a Node.js application and thus I could check the source code but I didn’t know how to debug it without a console.
Solution
If nssm can link Stdout to a file, we can debug with console.log().
The official page explains how to set it up.
It is explained in I/O redirection part.
We need to change the registry for it.
- Open
HKLM\System\CurrentControlSet\Services\servicename\Parameters - Add
AppStdoutthere - Set a file path for the log (e.g. “D:\nssm-app.log“) to the value
If the service name is “FileWatchService“, the registry is HKLM\System\CurrentControlSet\Services\FileWatchService\Parameters.
Then, all console log output is written to the file.
Why do I need it
Even if we use a logging module, it is not used in dependencies. If we can’t find the root cause from the thrown error, we need to look into the code. It can happen if a dependency uses timer related function or requires a callback because an error might not be exposed.
This is dull work but necessary.



Comments