I am extending an existing C project that prints all information to stdout
with printf
. I would like to have this information printed both to stdout AND to a log file.
If I were a contributor to the original project, I would just substitute all printf
calls with my custom log function. Alas, I am not, so here's my question:
Is it possible to redirect printf
so that a single call prints both to stdout
and to file?
I know this is a long shot but, if it were possible, I could obtain what I want without having to modify the original code.
EDIT: Thank you for the answer and comments about the tee
command. However, I am looking for a way to do it directly in the C code, in an automated fashion, so that users won't have to bother using tee.
Thank you for your attention!