how to rtPrintf() to a file?

I want to rtPrintf() to a local file, is there any method to do this?

Not directly. The prints goes to an internal buffer of user defined size. The buffer contents are printed to the standard output after a launch.
[url]https://raytracing-docs.nvidia.com/optix_6_0/api_6_0/html/group__rt_printf.html#ga9d99a9ef5eefa9cbe4125ff9af71075a[/url]
It’s just a debug functionality and should never be enabled in a release version of an app, so there is little functionality to control it.

Inside a command prompt you could route the standard output stream to a new file with the “>” symbol like this: app.exe > output.txt.
“2>” does the same for the standard error stream.